Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UINavigationBar set tintcolor tested in iOS7 not working?

I have an app which have a UINavigationBar and I have set the tint color to black like this:

self.navigationController.navigationBar.tintColor = [UIColor blackColor];`

I have tested it in IOS 6 and it's black. However, it appears as the default navigation bar when I tried the same app in iOS 7.

As the title says, is it not working?

like image 746
veereev Avatar asked Jun 11 '13 10:06

veereev


2 Answers

You need to set the barTintColor property.

You can specify a custom tint color for the navigation bar background using the Tint (barTintColor) field. The default background tint color is white.

From iOS7 docs: https://developer.apple.com/library/content/documentation/UserExperience/Conceptual/UIKitUICatalog/UINavigationBar.html#//apple_ref/doc/uid/TP40012857-UINavigationBar-SW1

like image 58
Hector Matos Avatar answered Nov 04 '22 20:11

Hector Matos


Fernando's and sanjana's answers have the key, but I'll just add something to make it clearer and more obvious.

The navigation bar has two properties

  • tintColor
  • barTintColor

It's a bit misleading when you don't think in iOS 7 terms.

tintColor changes the color of the buttons on your navigation bar. To change the background color, you need to set the property barTintColor.

self.navigationController.navigationBar.barTintColor = [UIColor whiteColor];
self.navigationController.navigationBar.tintColor = [UIColor greenColor];

This code snippet will give you a white navigation bar with green buttons.

like image 27
Irina Anastasiu Avatar answered Nov 04 '22 21:11

Irina Anastasiu