iOS开发中关于导航栏的一些设置
来源:互联网 发布:java 虚函数 编辑:程序博客网 时间:2024/06/15 16:16
1、设置导航栏的背景颜色:
导航栏的背景颜色默认是白色,修改方法:
self.navigationController.navigationBar.barTintColor = [UIColor greenColor];
//此方法中也可修改字体的大小
[self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor whiteColor]}];
self.title = @"导航栏标题";
3、自定义导航栏左侧返回的按钮(仅含有返回按钮,且改变系统蓝色的颜色)
UIImage *leftImage = [UIImage imageNamed:@"goBack_Yellow.png"];UIBarButtonItem *leftBarBI = [[UIBarButtonItem alloc]initWithImage:[leftImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] style:UIBarButtonItemStylePlain target:self action:@selector(slrootNavigationControllerDidClickBackBtn)];self.navigationItem.leftBarButtonItem = leftBarBI;
//返回事件
-(void)slrootNavigationControllerDidClickBackBtn{ [self.navigationController popViewControllerAnimated:YES];}
4、自定义导航栏右侧按钮(去掉右侧的“>”,且改变右侧文字颜色)
UIButton *achieveBtn = [UIButton buttonWithType:UIButtonTypeCustom]; achieveBtn.frame = CGRectMake(0, 0, 40*kWidthScale, 40*kWidthScale); [achieveBtn setTitle:@"完成" forState:UIControlStateNormal]; [achieveBtn setTitleColor:kButtonColor forState:UIControlStateNormal]; [achieveBtn addTarget:self action:@selector(topContactViewControllerWithRightBarButtonItem:) forControlEvents:UIControlEventTouchUpInside]; UIBarButtonItem *achieveBtnItem = [[UIBarButtonItem alloc]initWithCustomView:achieveBtn]; self.navigationItem.rightBarButtonItem = achieveBtnItem;
UIButton *settingButton = [UIButton buttonWithType:UIButtonTypeCustom]; //修改按钮向右偏移10 point [settingButton setFrame:CGRectMake(10.0, 0.0, 44.0, 44.0)]; [settingButton addTarget:self action:@selector(settingButtonOnClicked:) forControlEvents:UIControlEventTouchUpInside]; [settingButton setImage:[UIImage imageNamed:@"ic_main_setting"] forState:UIControlStateNormal]; //修改方法 UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, 44.0, 44.0)]; [view addSubview:settingButton]; UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:view];此方法来自:作者:紧张的牛排链接:http://www.jianshu.com/p/5f3eae0c0bd9
阅读全文
0 0
- iOS开发中关于导航栏的一些设置
- IOS关于设置导航栏的一些总结
- iOS导航栏的一些设置
- 关于导航栏设置的一些操作
- 关于iOS开发中隐藏导航栏的问题
- ios中导航栏的设置
- 关于一些iOS开发中容易忽略的一些属性设置
- iOS -- 导航栏和标签栏的一些设置
- iOS---导航条的一些设置
- 关于导航栏和状态栏的一些UI设置
- 关于导航栏透明和渐变的一些设置
- iOS开发之导航栏的一些小功能
- iOS开发之导航栏的一些小功能
- iOS关于导航设置的问题
- iOS开发之设置导航栏中间的title
- iOS 开发导航条的透明设置
- iOS导航栏的设置
- 关于导航栏的 设置
- CAD图纸怎么修改标注
- Eclipse 快捷键
- Unity3d之AssetBundle打包与读取
- java-内存区域
- iOS基础知识7
- iOS开发中关于导航栏的一些设置
- 分享一个自己用Java写的 PEdump 字节码查看器
- setsockopt()用法(参数详细说明)
- YTU.2665: 将十进制数对应的八进制、十六进制、十进制数输出
- pandas去重、缺失
- 生产者及消费者
- linux命令详解
- 服务发现比较:Consul vs Zookeeper vs Etcd vs Eureka
- 用Banner实现无线轮播的实现