iosobjective-cuinavigationcontrolleruinavigationbar

iOS Change NavigationBar appearance throughout entire app


I have multiple UINavigationController throughout my storyboard. Since I am using a tabbarcontroller every tab item has it's own UINavigationController embedded before it's ViewController.

I'd like to style all of these at the same time. Things that I have tried that work are going to a ViewControllers ViewWillAppear method and adding the following lines:

UINavigationBar *nav = self.navigationController.navigationBar;
nav.barStyle = UIBarStyleBlack;
nav.tintColor = [UIColor blackColor];
nav.translucent = NO;

But then I'd have to do this for every tab item and every ViewController.

Also, doing the following in the AppDelegate did NOT work:

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

Specifically I am curious why using the appearance proxy doesn't work. I'm fairly new so if you give a solution involving custom UINavigationController or setting up a delegate please elaborate. Thanks!


Solution

  • Add this line too in your code:

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