Created
October 13, 2011 16:50
-
-
Save gonecoding/1284766 to your computer and use it in GitHub Desktop.
Adding two ore more UIBarButtonItems to one side of an UINavigationItem (pre iOS 5.0)
This file contains 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
UIBarButtonItem* firstButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh target:self action:@selector(someSelector:)] autorelease]; | |
secondButtonItem.style = UIBarButtonItemStyleBordered; // must be set manually | |
UIBarButtonItem* secondButtonItem = [[[UIBarButtonItem alloc] initWithTitle:@"Title" style:UIBarButtonItemStyleBordered target:self action:@selector(someSelector:)] autorelease]; | |
UIToolbar* toolbar = [[[UIToolbar alloc] initWithFrame:CGRectMake( 0.0, 0.0, 100.0, 44.0 )] autorelease]; | |
toolbar.barStyle = -1; // removes background, undocumented, make break one day | |
toolbar.tintColor = self.navigationController.navigationBar.tintColor; | |
[toolbar setItems:[NSArray arrayWithObjects:firstButtonItem, secondButtonItem, nil] animated:NO]; | |
UIBarButtonItem* toolbarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:toolbar] autorelease]; | |
self.navigationItem.leftBarButtonItem = toolbarButtonItem; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment