對(duì)于導(dǎo)航欄顏色的變化,簡單的設(shè)置就是在每個(gè)ViewController這樣設(shè)置
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.navigationBar.barTintColor = [UIColor redColor];
}
但是顏色的切換會(huì)顯得比較的生硬髓涯,都是突變的档址。所以就有很對(duì)的方案來處理導(dǎo)航欄顏色的變化吞琐,使其看起來不會(huì)那么的生硬。9.1 的模擬器看起來是這樣的奔誓。
9.1
但10.2的系統(tǒng)在導(dǎo)航欄顏色的切換上做了一定的優(yōu)化斤吐,添加了一下漸變的效果。無需做過多的設(shè)置厨喂,只需要稍微注意一下和措,返回按鈕不能用系統(tǒng)默認(rèn)的,需要自己設(shè)置一下杯聚。
- (void)viewDidLoad {
[super viewDidLoad];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleDone target:self action:@selector(backLast)];
}
- (void)backLast {
[self.navigationController popViewControllerAnimated:YES];
}
然后就可以優(yōu)雅的切換導(dǎo)航欄顏色了>势拧!下面是10.2的模擬器的效果
10.2