6

I have been looking on this site and on other how to set the navigation bar tint change, I have seen examples but is not quite what I need so any help will be appreciated.

on my app delegate I have:

@synthesize window;
@synthesize tabBarController;
@synthesize navigationController;
@synthesize navigationController1;
@synthesize navigationController2;
@synthesize viewController;
@synthesize viewController2;
@synthesize viewController3;

#pragma mark -
#pragma mark Application lifecycle 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:              (NSDictionary *)launchOptions {    

    // Override point for customization after application launch.


    // Set the tab bar controller as the window's root view controller and display.
self.window.rootViewController = self.tabBarController;
[self.window makeKeyAndVisible];


    return YES;
}

When I enter the code self.navigationController.navigationBar setTintColor:[UIColor blackColor] on the above, it only changes one of my navigation controllers but not the one I need.

I have 7 items on my tabbar and when I press the "MORE..." I get a table view with the other items that do not fit on the main screen, the navigation bar is added automatically, and no matter what I do I can not change this navigation bar tint, I can change the ones that I have @synthesize but not the automatically entered one.

Can someone please let me know how to change the automatically placed navigation bar?

Andrey Zverev
  • 4,409
  • 1
  • 28
  • 34
Derek
  • 175
  • 1
  • 4
  • 16

2 Answers2

17

You can do this using the appearance proxy. If you set the colour like this it will apply to every navigation bar in the app:

[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];
Nick Lockwood
  • 40,865
  • 11
  • 112
  • 103
  • 1
    Just wanted to mention that the appearance proxy is only available in iOS 5. – Randall Feb 05 '12 at 17:15
  • As is the setTintColor method itself. If you need this stuff to work on iSO4 you'll need a different approach. Here's a discussion that links to some solutions: http://stackoverflow.com/questions/9150956/customizeappearance-compatibility-on-others-ios/9151033#9151033 – Nick Lockwood Feb 05 '12 at 17:20
3

For iOS 6 and lower:

[[UINavigationBar appearance] setTintColor:[UIColor blackColor]];

For iOS 7 and higher:

[[UINavigationBar appearance] setBarTintColor:[UIColor blackColor]];

Set it in this method in AppDelegate.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Zeezer
  • 1,503
  • 2
  • 18
  • 33