[ACCEPTED]-How to add custom color to navigation bar in iphone?-navigationbar
Accepted answer
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
[[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.
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
[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.
For swift, to change the tint of the navigation 1 bar background :
navigationController?.navigationBar.barTintColor = UIColor.red
Use like this,
UINavigationBar *bar = [self.navigationController navigationBar];
bar.barTintColor = [UIColor colorWithRed:0.5 green:0.5 blue:0.5 alpha:1.0];
0
Source:
stackoverflow.com
More Related questions
Cookie Warning
We use cookies to improve the performance of the site. By staying on our site, you agree to the terms of use of cookies.