Created
February 27, 2013 16:16
-
-
Save benvium/5049139 to your computer and use it in GitHub Desktop.
Animated replacement of self.navigationItem.rightBarButtonItem with an animated spinner, e.g. when network is busy. Sadly getting the layout right is hard - the width of the rightbarbuttonitem comes back as 0...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| UIActivityIndicatorView* spinner = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite]; | |
| spinner.hidesWhenStopped = YES; | |
| [spinner startAnimating]; | |
| UIView* view = [[UIView alloc] initWithFrame:CGRectZero]; | |
| view.frame = CGRectMake(0, 0, 20, 30); | |
| [view addSubview:spinner]; | |
| spinner.center = CGPointMake(width/2, 15); | |
| [self.navigationItem setRightBarButtonItem:[[UIBarButtonItem alloc] initWithCustomView:view] animated:YES]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment