-
Notifications
You must be signed in to change notification settings - Fork 14
Using UIActivityIndicatorView
Timothy Lee edited this page Mar 15, 2014
·
2 revisions
There is a built in loading indicator called UIActivityIndicatorView that you can use to display loading status. Follow the steps below to use the UIActivityIndicatorView
You can either drag the UIActivityIndicator view into your nib file or create it programatically.
- (void)viewDidLoad {
[super viewDidLoad];
UIActivityIndicatorView *indicatorView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
indicatorView.center = self.view.center;
[self.view addSubview:indicatorView];
}
There are two interesting properties that you might want to configure with the UIActivityIndicatorView:
- color. Set the color of the indicator view, and it will override the color of the UIActivityIndicatorViewStyle.
- hidesWhenStopped. When the animation is stopped, the indicator will be automatically hidden. It will become visible again if it is restarted.
This example assumes that the UIActivityIndicatorView is in the interface, either because it was linked via an IBOutlet or created programatically.
@interface
@property (nonatomic, strong) UIActivityIndicatorView *indicatorView;
@end
[self.indicatorView startAnimating];
[self.indicatorView stopAnimating];