Created
February 22, 2015 04:24
-
-
Save buymeasoda/e4dbefaca78521c75f9e to your computer and use it in GitHub Desktop.
Add buttons to right bar button item
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
UIToolbar *toolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0.0f, 0.0f, 100.0f, 44.0f)]; | |
self.countLabel = [[UILabel alloc] init]; | |
self.countLabel.text = [self characterCountRemaining:0]; | |
[self.countLabel sizeToFit]; | |
UIBarButtonItem *countLabelItem = [[UIBarButtonItem alloc] initWithCustomView:self.countLabel]; | |
UIBarButtonItem *tweetButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Tweet" style:UIBarButtonItemStylePlain target:self action:@selector(onTweet)]; | |
[toolBar setItems:@[countLabelItem, tweetButtonItem] animated:NO]; | |
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:toolBar]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment