//
//  UILoading.m
//  Minfo
//
//  Created by Nguyen Hieu on 1/3/13.
//  Copyright (c) 2013 Nguyen Hieu. All rights reserved.
//

#import "UILoading.h"

@implementation UILoading

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
    }
    return self;
}

-(id)initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ...
{
    [self initWithFrame:CGRectMake(10.0, 10.0, 100, 50.0)];
    

    UIActivityIndicatorView *loading = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(20.0, 27, 20, 20)];
    [loading startAnimating];
    [loading setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
    [self addSubview:loading];
    
    
    UILabel *lbl = [[UILabel alloc]initWithFrame:CGRectMake(50, 28, 160, 17.0)];
    if([Utility GET_IOS_VERSION]<6)
    {
        [lbl setTextAlignment:UITextAlignmentLeft];
    }
    else{
        [lbl setTextAlignment:NSTextAlignmentLeft];
    }
    
    
    [lbl setFont:[UIFont boldSystemFontOfSize:14]];
    [lbl setText:NSLocalizedString(@"Loading...", nil)];
    [lbl setBackgroundColor:[UIColor clearColor]];
    [lbl setTextColor:[UIColor whiteColor]];
    [self addSubview:lbl];
    
    
    [self setDelegate:self];
    return self;
}
- (void)willPresentAlertView:(UIAlertView *)alertView {
	[alertView setFrame:CGRectMake(5, 20, 150, 75)];
	alertView.center = CGPointMake(IS_WIDTH / 2, IS_HEIGHT / 2);
}

@end
