How to add custom color to navigation bar in iphone?

Rani picture Rani · Apr 7, 2011 · Viewed 30k times · Source

How do I set the navigation bar to a custom color (e.g. dark green) ?

I know how to change the navigation bar to primary colors like green and red, using code like this:

UINavigationBar *bar = [self.navigationController navigationBar]; 
[bar setTintColor:[UIColor redColor]]; 

Thanks.

Answer

Jim Blackler picture Jim Blackler · Apr 7, 2011

Using RGB values like this:

UINavigationBar *bar = [self.navigationController navigationBar];
[bar setTintColor:[UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:1.0]];