My application 开发者_高级运维has a navigation view controller with 2 views :
- a root view : i'd like the tint color for its navigation bar to be black - a sub view : i'd like the tint color for its navigation bar to be blueTo achieve this, I set the tint color for the navigation bar in the viewDidLoad method of each view controller :
self.navigationController.navigationBar.tintColor = [UIColor blackColor];
My problem is that during the tests :
- step 1 - i access the root view : the navigation bar is black : OK - step 2 - i push the subview : the navigation bar is blue : OK - step 3 - i click on the "back" button of the subview : the navigation remains blue : KOIs there any add code I should add to obtain the behavior I want ? (i've tried some dirty workarounds like calling drawRect in viewWillAppear but it does not work)
Thanks for your help !
You should be able to do the self.navigationController.navigationBar.tintColor = [UIColor blackColor];
in viewWillAppear
or viewDidAppear
The reason is that the navigationController is shared. So, when you change its color to Blue, you have to change it back to Black.
The best way is like Elfred said, you should do it in viewWillAppear
精彩评论