标签:style color os io ar for art cti sp
导航控制器常用函数触发时机当视图控制器的View将要出现时触发
- (void)viewWillAppear:(BOOL)animated
当视图控制器的View已经出现时触发
- (void)viewDidAppear:(BOOL)animated
当视图控制器的View将要消失时触发
- (void)viewWillDisappear:(BOOL)animated
当视图控制器的View已经消失时触发
- (void)viewDidDisappear:(BOOL)animated
当由前一个界面,push下一个界面时,如A push
B,四个方法执行顺序A(ViewWillDisappear)>B(viewWillAppear)>A(viewDidDisappear)>B(viewDidAppear)
当由后一个界面pop前一个界面时,如B pop A,四个方法执行顺序B(viewWillDisappear)>A(viewWillAppear)>B(viewDidDisappear)>A(viewDidAppear)
navigationBar常用属性
一. 对navigationBar直接配置,所以该操作对每一界面navigationBar上显示的内容都会有影响(效果是一样的)
1.修改navigationBar颜色
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
2.关闭navigationBar的毛玻璃效果
self.navigationController.navigationBar.translucent = NO;
3.将navigationBar隐藏掉
self.navigationController.navigationBarHidden = YES;
4.给navigationBar设置图片
不同尺寸的图片效果不同:
1.320 * 44,只会给navigationBar附上图片
2.高度小于44,以及大于44且小于64:会平铺navigationBar以及状态条上显示
3.高度等于64:整个图片在navigationBar以及状态条上显示
[self.navigationController.navigationBar setBackgroundImage:[UIImage imageNamed:@"32050"] forBarMetrics:UIBarMetricsDefault];
二.为每一个界面的navigationBar上显示的内容单独定制(每个界面显示内容不一样)
单独定制,修改视图控制器的navigationItem
1.设置界面的title
self.navigationItem.title = @"远东大开发”;
2.修改titleView(中间显示视图)
UISegmentedControl *segment = [[UISegmentedControl
alloc]
initWithItems:@[@"分组",
@"好友"]]; self.navigationItem.titleView
= segment;[segment release];
3.修改navigationBar的颜色self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
4.修改navigationBar,右边显示内容
UIBarButtonItem *right = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(add:)];
self.navigationItem.rightBarButtonItem = right;
[right release];
5.修改navigationBar,左侧显示内容
UIBarButtonItem *left = [[UIBarButtonItem
alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemAdd
target:self
action:@selector(add:)];
self.navigationItem.leftBarButtonItem
= left;
[left release];
iOS导航控制器常用函数与navigationBar常用属性
标签:style color os io ar for art cti sp
原文地址:http://blog.csdn.net/hakusan/article/details/39026403