UINavgationViewController
2015-10-20 14:26
267 查看
一. 设置全部导航条的背景
// 取出全部导航条UINavigationBar *bar = [UINavigationBar appearance];
// 设置全部导航条的背景图片
[bar setBackgroundImage:[UIImage imageName: @"navigationbar_background.png"] forBarMetrics:UIBarMetricsDefault];
// 导航栏上有一层BackgroundImageView,不能直接设置背景颜色,设置背景颜色是无效的
// bar.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"navigationbar_background.png"]];
// 设置导航栏文字的主题
[bar setTitleTextAttributes:@{
UITextAttributeTextColor : [UIColor darkGrayColor] UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetZero]
}];
二.设置导航条上所有Item
// 设置全部item的背景// 取出导航条上所有item
UIBarButtonItem *items = [UIBarButtonItem appearance];
// 设置item的背景
[items setBackgroundImage:[UIImage imageNamed:@"navigationbar_button_background.png"] forState:UIControlStateNormal barMetrics:UIBarMetricsDefault];
[items setBackgroundImage:[UIImage imageNamed:@"navigationbar_button_background_pushed.png"] forState:UIControlStateHighlighted barMetrics:UIBarMetricsDefault];
// 设置item的文字主题
NSDictionary *dict = @{UITextAttributeTextColor : [UIColor darkGrayColor],
UITextAttributeTextShadowOffset : [NSValue valueWithUIOffset:UIOffsetZero],
UITextAttributeFont : [UIFont systemFontOfSize:13]
};
[items setTitleTextAttributes:dict forState:UIControlStateNormal];
[items setTitleTextAttributes:dict forState:UIControlStateHighlighted];
三.设置状态栏模式
// 设置状态栏,因为给导航条设置了颜色,状态栏会随着导航条的颜色改变而改变,所以我们需要设置为黑色。[UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleBlackOpaque;
四.导航控制器不能设置左右item和中间的文字,导航控制器本身不具备显示功能,他是通过跟控制器显示的,不要傻乎乎的给导航控制器设置左右item。
五.如果需要在跳转页面的时候,做一些操作效果,可以自定义导航控制器重写push或者pop方法(重写这个方法,也可以取消一些不想要的效果),或者作为导航控制器的代理,监听跳转方法。
- (void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
相关文章推荐
- UITableview中的backgroundView
- 探秘Java中的String、StringBuilder以及StringBuffer
- Android build system & Android.mk 规范
- UIImageView显示问题
- iOS之UI高级---触摸事件
- iOS工作中的问题-----navigationBar透明方法、遮挡UIViewController、UITableViewController 视图解决方法
- Leetcode Unique Paths II
- GRUB- "No suitable mode found"
- Request的getParameter和getAttribute方法的区别
- Druid简介
- 自定义一个LTView对象,本身自带一个UILable和一个UITextField控件
- UE如何改变点击上传图片的弹出框的大小...
- PROPAGATION_REQUIRED
- svn: Failed to run the WC DB work queue associated with
- Foundation 心得、笔记
- 使用RequireJS优化Web应用前端
- UIRefreshControl
- finished with non-zero exit value -1073741819
- UIAlertController
- Leetcode Unique Paths