5

This is what I want. It loads on some of my view controllers.

Hi all,

I am going nuts trying to make the tint color of all of my viewControllers the same. Some appear to be much darker than others. All I want is the light color to be throughout...

This is what I want

Sometimes I get this ugly dark gray instead... I am not sure what I am doing incorrectly. I have checked the .m file and am not setting the tint color or anything... not sure why it wouldnt be consistent on every viewController...

This is what I get

Any help would be great. Thanks!

Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
user2492064
  • 591
  • 1
  • 8
  • 21
  • 1
    Behavior from some of the properties of `UINavigationBar` has changed from `iOS 7`. I already explained in detail in my [Answer](http://stackoverflow.com/a/19029973/1603072). – Bhavin Oct 10 '13 at 07:27

3 Answers3

17

in iOS7 navigation bar is by default translucent=YES so just change to NO like bellow:-

self.navigationController.navigationBar.translucent=NO;

and set Navigaitonbar color or other property customize like Bellow put this code into Appdelegate class didFinishLaunchingWithOptions and use appearance for applying Globally:-

if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_6_1) {

    // Load resources for iOS 6.1 or earlier
     [[UINavigationBar appearance]setTintColor:NavigationColor];
} else {
     [[UINavigationBar appearance]setTintColor:[UIColor whiteColor]]; // it set color of bar button item text
     [[UINavigationBar appearance]setBarTintColor:[UIColor GreenColor]]; // it set color of navigation
     [[UINavigationBar appearance] setBarStyle:UIBarStyleDefault]; // it set Style of UINavigationBar
     [[UINavigationBar appearance]setTitleTextAttributes:@{UITextAttributeTextColor : [UIColor whiteColor]}]; //It set title color of Navigation Bar
    // Load resources for iOS 7 or later

}

For tabBar also same this is by default translucent=YES change to NO

[self.tabBarController.tabBar setTranslucent:NO];
Nitin Gohel
  • 49,482
  • 17
  • 105
  • 144
  • Thanks! OK that seems to work if I place it in my viewDidLoad method, but why cant I change the color? I put `self.navigationController.navigationBar.translucent=NO;` in the viewDidLoad method, but I want to change the color to blueColor. I am targeting ios7 – user2492064 Oct 10 '13 at 07:32
  • at app delegate class **[[UINavigationBar appearance]setBarTintColor:[UIColor blueColor]];** or at viewDidLoad **self.navigationController.navigationBar setBarTintColor:[UIColor blueColor]];** – Nitin Gohel Oct 10 '13 at 07:34
  • Yes for tab bar same this is by default translucent=YES change to NO – Nitin Gohel Oct 10 '13 at 07:44
  • use appearance so no need to put code in each class in `viewDidLoad` Method take a look my updated answer. – Nitin Gohel Oct 10 '13 at 07:53
4

A common mistake is setting the view.backgroundColor of the View Controller to clearColor (both programmatically or via Storyboard). This makes the view actually black instead (since there's nothing beneath the clear view), so everything that is above that view, that has translucent property set to YES, will show dark grey color (black color + default iOS blur).

To fix this, either set the translucent property to NO (as Nitin Gohel said), or set the view.backgroundColor to white, which's its actual default color.

Hope this still helps someone!

Roger Oba
  • 1,292
  • 14
  • 28
0

Since iOS 7.1 there's a bug, which causes UITabBar to not listen to Global Tint.

See this post: https://stackoverflow.com/a/22323786/1255674

You need to set the tint programmatically. Thanks, Ive ...

Community
  • 1
  • 1
Robert
  • 431
  • 7
  • 19