UINavicationController基本应用
来源:互联网 发布:php微商城开源系统 编辑:程序博客网 时间:2024/05/12 09:42
UINavicationController 导航栏,顾名思义为视图与视图之间切换的桥梁,简单来说,就是用来控制视图之间的跳转
请看以下代码分析:
- // 设置navigationbar的半透明效果
- self.navigationController.navigationBar.translucent = NO;
- [self.navigationController.navigationBar setTranslucent:NO];
- // 设置navigationbar上显示的标题
- self.title = @"navigationcontroller";
- // 设置navigationbar的颜色
- [self.navigationController.navigationBar setBarTintColor:[UIColor purpleColor]];
- // 设置navigationbar左边按钮
- self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonItemStyleDone target:self action:Nil];
- // 设置navigationbar右边按钮
- self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonItemStylePlain target:self action:Nil];
- // 也可以自定义navigationbar 左右的按钮
- 思路:新建按钮控件rightbtn,然后 initWith rightbtn 得到UIBarButtonItem,最后赋值给rightBarButtonItem
- // 设置navigationbar上左右按钮字体颜色
- [self.navigationController.navigationBar setTintColor:[UIColor blueColor]];
设置导航条里面分段效果
- // 设置navigation上的titleview
- NSArray *arr = [NSArray arrayWithObjects:@"左边",@"右边", nil nil];
- UISegmentedControl *segment = [[UISegmentedControl alloc] initWithItems:arr];
- segmentedController.segmentedControlStyle = UISegmentedControlSegmentCenter;
- //添加点击事件
- [segmentedController addTarget:self action:@selector(segmentClick:) forControlEvents:UIControlEventValueChanged];
- self.navigationItem.titleView = segment;
UISegmentedControl 分段控制,这个分段可以分为两个视图来控制,添加点击事件,根据index判断哪个分段被点击,执行相应的操作。
- -(IBAction)segmentClick:(id)sender
- {
- switch ([sender selectedSegmentIndex]) {
- case 0:
- {
- UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"提示" message:@"你点击了左边" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
- [alter show];
- //执行相应的操作
- }
- break;
- case 1:
- {
- UIAlertView *alter = [[UIAlertView alloc] initWithTitle:@"提示" message:@"你点击了右边" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil];
- [alter show];
- //执行相应的操作
- }
- break;
- default:
- break;
- }
- }
如何结合UITabbarController 一起使用,敬请期待
0 0
- UINavicationController基本应用
- TWebBrowser的基本应用
- Tomcat的基本应用
- MySQL的基本应用
- Log4j的基本应用
- 锁的基本应用
- SQL的基本应用
- Log4j的基本应用
- TWebBrowser的基本应用
- TWebBrowser的基本应用
- 基本存储过程应用
- AJAX基本应用
- JavaScript基本应用
- JNDI基本应用(转载)
- 的基本应用
- spread的基本应用
- TWebBrowser的基本应用
- TWebBrowser的基本应用
- Android Framework的启动
- activity state save
- delphi 10 seattle 安卓服务开发(一)
- UVA 1339 - Ancient Cipher
- Qt bool转QString再转回bool方法
- UINavicationController基本应用
- 二分法查找
- android四大组件--ContentProvider详解
- 分割超大Redis数据库例子
- 图片下载缓存库Picasso清除缓存方法
- WebRTC 学习笔记(1)--总述
- 正则表达式
- spark mllib predict stock price
- php超时处理