Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing UIActivityIndicator's color while animating

Is it possible to change the color of UIActivityIndicatorView while it is still animating? if anyone have had this issue, then you can suggest me

like image 473
ytpm Avatar asked Dec 08 '22 17:12

ytpm


2 Answers

I just tried the following code in a view controller class, and it worked on iOS 5+

#import "ViewController.h"

@interface ViewController ()

@property UIActivityIndicatorView *activityIndicator;

@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.

    [self.view setBackgroundColor:[UIColor clearColor]];

    _activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
    [_activityIndicator setCenter:self.view.center];

    [self.view addSubview:_activityIndicator];
    [_activityIndicator startAnimating];

    [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(changeColor) userInfo:nil repeats:NO];
}

- (void)changeColor
{
    _activityIndicator.color = [UIColor redColor];
}

@end
like image 175
Saurabh G Avatar answered Dec 11 '22 10:12

Saurabh G


I found one Beautiful Link for you : ActivityIndicators

I think you should try : Custom Activity Indicator.

You can change the UIActivityIndicatorStyle from any of these :

UIActivityIndicatorViewStyleWhiteLarge,
UIActivityIndicatorViewStyleWhite,
UIActivityIndicatorViewStyleGray,

Hope It helps !!!

like image 27
Bhavin Avatar answered Dec 11 '22 11:12

Bhavin