`
jsntghf
  • 浏览: 2482418 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

导航栏中添加多个UIBarButtonItem

    博客分类:
  • iOS
阅读更多

UIToolbar *tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 95, 45)];
[tools setTintColor:[self.navigationController.navigationBar tintColor]];
[tools setAlpha:[self.navigationController.navigationBar alpha]];

NSMutableArray *buttons = [[NSMutableArray alloc] initWithCapacity:2];
UIBarButtonItem *button1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
																																				 target:self action:@selector(btnClick:)];
UIBarButtonItem *button2 = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UITabBarSystemItemContacts target:self action:@selector(btnClick:)];
[buttons addObject:button1];
[button1 release];
[buttons addObject:button2];
[button2 release];
[tools setItems:buttons animated:NO];
[buttons release];

UIBarButtonItem *myBtn = [[UIBarButtonItem alloc] initWithCustomView:tools];
self.navigationItem.rightBarButtonItem = myBtn;

[myBtn release];
[tools release];

 

示例图:

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics