Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change navigation bar color in iOS 7 or 6?

I want to change the color of the navigation bar color, but I'm not sure whether or not I should change the tint or the background. I know iOS 7 is going for a more flat design (even recommending removing gradients), but I am having trouble deciphering the two. Even if I set a background color, it doesn't do anything.

In this image, the background is set to green, but the bar is still blue:

Enter image description here

like image 867
EGHDK Avatar asked Aug 11 '13 21:08

EGHDK


People also ask

How can I change navigation bar color?

Tap the Gear icon next to Active App on the home screen and you can disable coloring for certain apps, or override the default color if you'd prefer another. If you'd rather keep it at one color, choose Static Color on the home screen. Tap the Gear to select your color. This is all you need to get a colored status bar.

Can you change Iphone navigation bar?

A user changes the navigation bar's style, or UIBarStyle , by tapping the “Style” button to the left of the main page. This button opens an action sheet where users can change the background's appearance to default, black-opaque, or black- translucent.


2 Answers

The behavior of tintColor for bars has changed on iOS 7.0. It no longer affects the bar's background and behaves as described for the tintColor property added to UIView. To tint the bar's background, please use -barTintColor.

navController.navigationBar.barTintColor = [UIColor navigationColor];

like image 86
Mahesh Avatar answered Sep 20 '22 22:09

Mahesh


If you want to have a solid color for your navigation bar in iOS 6 similar to iOS 7 use this:

[[UINavigationBar appearance] setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault]; [[UINavigationBar appearance] setBackgroundColor:[UIColor greenColor]]; 

in iOS 7 use the barTintColor like this:

navigationController.navigationBar.barTintColor = [UIColor greenColor]; 

or

 [[UINavigationBar appearance] setBarTintColor:[UIColor greenColor]]; 
like image 21
carmen Avatar answered Sep 19 '22 22:09

carmen