1.右边的rightBarButtonItem设置颜色方法是设置tint color来实现的
[self.navigationItem.rightBarButtonItem setTintColor:[UIColor blackColor]];
2.当遇见该弹出或者推出窗口的时候没有动静反应,或者控制台输出
NSBundle <xxx(路径)/xxx.app/xxxResource.bundle> (not yet loaded)
或者
[MC] System group container for [systemgroup.com.apple.configurationprofiles](systemgroup.com.apple.configurationprofiles) path is /private/var/containers/Shared/SystemGroup/[systemgroup.com.apple.configurationprofiles](systemgroup.com.apple.configurationprofiles)
[MC] Reading from public effective user settings.
报错时,应该要考虑是控制器push 或者 present方法没有统一,统一用push或者present,否则会有冲突
3.当前控制器设置导航栏隐藏,用
self.navigationController.navigationBar.hidden = NO;
会没有效果,需要调用set方法才可以
[self.navigationController setNavigationBarHidden:NO];
4.设置导航栏为透明
原理:在视图即将出现的时候设置一个新建图片对象,即将消失时恢复原有的背景图片,影子图片质为nil
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[UIImage new]];
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[self.navigationController.navigationBar setBackgroundImage:nil forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:nil];
}
以上是单独设置,全局设置导航栏背景的方式是在navigationController viewDidLoad 方法里统一设置背景图片
[self.navigationBar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
5.设置导航栏标题颜色
原理:navigationBar 有一个标题字典属性,在字典里面设置字体颜色和大小
self.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName:[UIFont boldSystemFontOfSize:18]};