Reputation: 499
How do I add an activity indicator to my toolbar, like the Mail app does when it is checking for email?
Upvotes: 10
Views: 3885
Reputation: 1
In storyboard this is easy. Just drag a view onto the toolbar and then drag on the activity indicator into that.
Upvotes: 0
Reputation: 58067
If you want to add it through code, not though interface builder, you need to:
Here's a code sample:
- (void) showActivityIndicator{
UIActivityIndicatorView *activityView = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
[activityView startAnimating];
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:activityView];
NSArray *items = [[NSArray alloc] initWithObjects:item, nil];
[self.navigationController.toolbar setItems:items];
[items release];
[activityView release];
}
Upvotes: 15
Reputation: 38012
Try dragging a UIProgressView onto you UIToolbar in interface builder. Should just work.
Upvotes: 0