iOS 开发中在导航栏添加多个按钮并改变它的位置
来源:互联网 发布:上海大承网络 空中网 编辑:程序博客网 时间:2024/05/21 17:01
跳过普通的设置左右按钮我们直接讲解给导航栏设置多个按钮 实现代码如下
<span style="font-size:18px;">UIToolbar *tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 100, 45)];</span>
<span style="font-size:18px;"> [tools setTintColor:[self.navigationController.navigationBar tintColor]];</span>
<span style="font-size:18px;"> [tools setAlpha:[self.navigationController.navigationBar alpha]];</span>
<span style="font-size:18px;"> NSMutableArray *buttons = [[NSMutableArray alloc] initWithCapacity:2]; </span>
<span style="font-size:18px;"> UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(clickSettings:)];</span>
<span style="font-size:18px;"> UIBarButtonItem *anotherButton1 = [[UIBarButtonItem alloc] initWithTitle:@"编辑" style:(UIBarButtonItemStylePlain) target:self action:@selector(clickEdit:)];</span>
<span style="font-size:18px;"> anotherButton1.tintColor = [UIColor redColor]; [buttons addObject:anotherButton];</span>
<span style="font-size:18px;"> [buttons addObject:anotherButton1]; [tools setItems:buttons animated:NO]; UIBarButtonItem *myButton = [[UIBarButtonItem alloc] initWithCustomView:tools]; self.navigationItem.rightBarButtonItem = myButton;</span>
<span style="font-size:18px;">- (void)clickSettings:(UIBarButtonItem *)clickSettings{ NSLog(@"我是添加按钮");}</span>
<span style="font-size:18px;">- (void)clickEdit:(UIBarButtonItem *)clickEdit{ NSLog(@"我是编辑按钮");}</span>
0 0
- iOS 开发中在导航栏添加多个按钮并改变它的位置
- IOS开发:导航栏添加多个按钮以及在左边添加logo
- ios导航栏添加多个按钮
- ios----导航栏添加多个按钮
- iOS 修改导航栏按钮的位置
- 在iOS导航栏的右上角添加按钮
- iOS中为导航栏的右上方添加各种按钮
- ios导航添加多个按钮 自定义按钮之间的距离
- iPhone开发在导航条中添加Info Light按钮
- ios 导航栏放置多个按钮
- IOS在UINavigation的rightBarButton上添加多个按钮
- IOS 改变导航栏返回按钮的标题
- IOS 改变导航栏返回按钮的标题
- iOS全局改变导航栏的返回按钮
- iOS 调整导航栏返回按钮的位置
- iOS在控制器导航栏右上角添加按钮
- iOS在控制器导航栏右上角添加按钮
- IOS开发(10)UIBarButtonItem导航栏添加按钮
- css
- Hdu 1087 Super Jumping! Jumping! Jumping!【最大上升子序列和】
- Android系统截屏的实现分析
- Java学习推荐书目
- 文章标题
- iOS 开发中在导航栏添加多个按钮并改变它的位置
- MFC学习-第2,3课 MFC框架的运行机制
- 【Spring3】(1)初识Spring
- 生成二维码代码
- Oracle数据库order by排序之null值处理方法
- RequireJS Adding a Library
- 设置NavigationControl的字体和背景色
- pushad & pushfd
- NSString 常用方法