开发者

How to change navigation bar background and text color of 'more' tab in the most efficient way?

开发者 https://www.devze.com 2023-03-28 06:48 出处:网络
I am using the following UINavigation delegate method in my app delegate to update the navigation bar background and text color for all my view controllers (so that I do not have to repeat code for ev

I am using the following UINavigation delegate method in my app delegate to update the navigation bar background and text color for all my view controllers (so that I do not have to repeat code for every view controller in the stack.

- (void)navigationController:(UINavigationController *)navigationController开发者_如何学Python 
  willShowViewController:(UIViewController *)viewController animated:(BOOL)animated

This has been working fine for all my tabs in the app except for the "more" tab. I now have more than one view controller in the 'more tab'

Is it possible to invoke the UINavigation delegate method for the 'more' tab as well? Else what is the best alternative to change the navbar and text color of all the view controllers in the more tab without repeating code for all the view controllers.


I've needed to do the same thing many times. My solution is to create a super class that inherits UIViewController and then customizes the nav bar in view did load. Then inherit this super class with all of your view controllers.

This solution puts all of your custom nav bar changes into one spot so if you want to change colors or add images you only have to do it in that one superclass. This is a great use of inheritance and code reuse which will keep your classes free of duplicated code.

0

精彩评论

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