NavigationController导航栏中添加多个UIBarButtonItem
来源:互联网 发布:美工不错的网站 编辑:程序博客网 时间:2024/05/17 19:22
NavigationController导航栏中添加多个UIBarButtonItem
在实际的开发中,导航器是最重要的容器之一,我们经常要在导航栏中添加各种样式的按钮,添加一个按钮很简单,代码如下图:
UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:@"Setting" style:UITabBarSystemItemContacts
target:self action:@selector(clickSettings:)];
self.navigationItem.rightBarButtonItem = anotherButton;
[anotherButton release];
其中按钮的样式可以有多种,具体的可以参考:https://developer.apple.com/library/ios/prerelease/#documentation/UIKit/Reference/UIBarButtonItem_Class/
在有些项目中要在右面添加两个按钮,实现的样式如下图:
UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 150, 45)];
[tools setTintColor:[self.navigationController.navigationBar tintColor]];
[tools setAlpha:[self.navigationController.navigationBar alpha]];
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:2];
UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self action:@selector(clickSettings:)];
UIBarButtonItem *anotherButton1 = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UITabBarSystemItemContacts
target:self action:@selector(clickEdit:)];
[buttons addObject:anotherButton];
[anotherButton release];
[buttons addObject:anotherButton1];
[anotherButton1 release];
[tools setItems:buttons animated:NO];
[buttons release];
UIBarButtonItem *myBtn = [[UIBarButtonItem alloc] initWithCustomView:tools];
self.navigationItem.rightBarButtonItem = myBtn;
[myBtn release];
在实际的开发中,导航器是最重要的容器之一,我们经常要在导航栏中添加各种样式的按钮,添加一个按钮很简单,代码如下图:
UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:@"Setting" style:UITabBarSystemItemContacts
target:self action:@selector(clickSettings:)];
self.navigationItem.rightBarButtonItem = anotherButton;
[anotherButton release];
其中按钮的样式可以有多种,具体的可以参考:https://developer.apple.com/library/ios/prerelease/#documentation/UIKit/Reference/UIBarButtonItem_Class/
在有些项目中要在右面添加两个按钮,实现的样式如下图:
UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 150, 45)];
[tools setTintColor:[self.navigationController.navigationBar tintColor]];
[tools setAlpha:[self.navigationController.navigationBar alpha]];
NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:2];
UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self action:@selector(clickSettings:)];
UIBarButtonItem *anotherButton1 = [[UIBarButtonItem alloc] initWithTitle:@"Edit" style:UITabBarSystemItemContacts
target:self action:@selector(clickEdit:)];
[buttons addObject:anotherButton];
[anotherButton release];
[buttons addObject:anotherButton1];
[anotherButton1 release];
[tools setItems:buttons animated:NO];
[buttons release];
UIBarButtonItem *myBtn = [[UIBarButtonItem alloc] initWithCustomView:tools];
self.navigationItem.rightBarButtonItem = myBtn;
[myBtn release];
[tools release];
摘自 计算机学习村落
- NavigationController导航栏中添加多个UIBarButtonItem
- NavigationController导航栏中添加多个UIBarButtonItem
- NavigationController导航栏中添加多个UIBarButtonItem
- NavigationController导航栏中添加多个UIBarButtonItem
- NavigationController导航栏中添加多个UIBarButtonItem
- NavigationController导航栏中添加多个UIBarButtonItem
- NavigationController导航栏中添加多个UIBarButtonItem
- NavigationController导航栏中添加多个UIBarButtonItem
- 导航栏中添加多个UIBarButtonItem
- UINavigationController导航栏中添加多个UIBarButtonItem
- 如何给UIToolBar 添加 多个UIBarButtonItem
- 7.30 iOS 5.0中,导航条引入了 在一侧设置多个UIBarbuttonItem方法
- IOS开发(10)UIBarButtonItem导航栏添加按钮
- mono touch中NavigationController构造导航栏和工具栏
- 导航栏添加多个按键
- ios导航栏添加多个按钮
- ios----导航栏添加多个按钮
- NavigationController 设置导航栏主题
- 获得指定类的方法
- iOS开发进行真机调试
- 获得方法参数类型
- 执行指定方法
- 关于struts2后台接受jquery ajax提交的复杂对象
- NavigationController导航栏中添加多个UIBarButtonItem
- hadoop单机版搭建图文详解 (转)
- qTip2 Events
- 以WordPress为例——教你如何把传统网站搬到云上
- C/C++字节对齐简述
- 【Visual C++】游戏开发笔记三十 DirectX11 2D纹理映射知识全攻略
- Struts2配置文件讲解
- hdu 1297 Children’s Queue(递推+大数)
- 【javaWeb】div居中