Friday, August 8, 2014

iOS Code: Implementing UIActivityIndicator

-(void) viewDidLoad
{

...

    UIActivityIndicatorView *ai = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    ai.center = self.view.center;
    ai.hidesWhenStopped = YES;
    ai.hidden = YES;
    ai.color = [UIColor blackColor];
    // [[ai.layer setBackgroundColor:CFBridgingRetain([UIColor whiteColor])];
    self.activityIndicator = ai;

    [self.view addSubview:self.activityIndicator];


}

- (void) threadStartAnimating:(id)data {

    self.activityIndicator.hidden = NO;
    
    [self.activityIndicator startAnimating];

}

// line to start animation
    [NSThread detachNewThreadSelector:@selector(threadStartAnimating:) toTarget:self withObject:nil];


// line to stop animation
        [self.activityIndicator stopAnimating];

No comments:

Post a Comment