1.设置导航栏标题
self.navigationItem.title = @"标题短发短发短发";
2.设置item颜色(返回按钮颜色--并不是标题颜色)
[self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
3.设置导航栏背景色
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
4.导航栏背景图片(同时使用方法3 方法3会失效)
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
5.设置导航条标题的字体大小和颜色
self.navigationController.navigationBar.titleTextAttributes=@{NSForegroundColorAttributeName:[UIColor redColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:12]};
6.导航栏的下边线
[self.navigationController.navigationBar setShadowImage:[UIImage new]];//导航栏的的下边线
7.状态栏的颜色
self.navigationController.navigationBar.barStyle = 1;
8.设置导航条颜色渐变
[self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
[self.navigationController.navigationBar setShadowImage:[UIImage new]];//导航栏的的下边线
UIImageView * viewa = self.navigationController.navigationBar.subviews.firstObject;//导航栏的view
viewa.alpha = 0;
[UIView animateWithDuration:2 animations:^{
UIImageView * view = self.navigationController.navigationBar.subviews.firstObject;
view.alpha = 1;
view.backgroundColor = [UIColor colorWithRed:0.110 green:0.500 blue:1.000 alpha:1.000];
}];
9.设置隐藏导航条(动画)
[self.navigationController setNavigationBarHidden:YES animated:YES];
10.自定义标题View
UILabel *title = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];
title.text = @"title3";
title.textAlignment = NSTextAlignmentCenter;
title.textColor = [UIColor redColor];
self.navigationItem.titleView = title;