SpaceDog SpaceDog - 1 year ago 71
iOS Question

Changing the NavigationBar chevron and title color has no effect

I am trying to set the color of the navigation bar's back button and chevron of the back button.

My app starts with a navigation controller.

This navigation controller has a custom class withe these lines:

- (void)awakeFromNib {
[super awakeFromNib];

UIColor *white = [UIColor whiteColor];
[self setTintColor: white];
// [self setBarTintColor: white];

UIFont *fonte = [UIFont fontWithName:@"Avenir-Book" size:14.0f];
NSDictionary *atributos = @{NSForegroundColorAttributeName : white,
NSFontAttributeName : fonte

[self setTitleTextAttributes:atributos];


The root view controller of that navigation controller has the navigation bar hidden. This root view controller is called main screen.

From that view controller I push another one that has the navigation bar visible. That navigation bar has no back button added by me but iOS puts a back button and a chevron there "< main screen". That button and the chevron are both back.

Aren't these supposed to respect the settings on the navigation bar class that make those items white?

What is wrong?

Answer Source

To globally set that color you could use something like this in you AppDelegate:

UINavigationBar *navBarAppearance = [UINavigationBar appearance];
[navBarAppearance setTintColor:[UIColor greenColor]];

Or in Swift:

let navBarAppearace = UINavigationBar.appearance()
navBarAppearace.tintColor = UIColor.greenColor()