Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS7 navigationBar and TabBar Color is behaving strangely

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!

like image 775
user2492064 Avatar asked Oct 10 '13 07:10

user2492064


2 Answers

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];
like image 178
Nitin Gohel Avatar answered Sep 22 '22 04:09

Nitin Gohel


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!

like image 35
Roger Oba Avatar answered Sep 22 '22 04:09

Roger Oba