开发者

Different navigation bar tints inside 1 single navigation controller?

开发者 https://www.devze.com 2023-01-04 19:45 出处:网络
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

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 blue

To 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 : KO

Is 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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号