[ACCEPTED]-How to add custom color to navigation bar in iphone?-navigationbar

Accepted answer
Score: 21

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]];

0

Score: 14
[[UINavigationBar appearance] setTintColor:[UIColor colorWithRed:107.0/255.0 green:145.0/255.0 blue:35.0/255.0 alpha:1.0]]; 

Place this code in Appdelegate's didfinislaunching method.It 2 will change the color of the navigation 1 bar for the whole app.

Score: 4

And to change the tint of the navigation bar background :

[self.navBar setBarTintColor:[UIColor colorWithRed:0.701 green:0.926 blue:0.000 alpha:1.000]];

0

Score: 3
[bar setTintColor:[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0]]

There are many other ways of getting your 2 color from different kinds of components 1 as described in the documentation.

Score: 3

For swift, to change the tint of the navigation 1 bar background :

navigationController?.navigationBar.barTintColor = UIColor.red
Score: 1

Use like this,

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

0

More Related questions