Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Navigation Bar background color

I am new to iOS development, I facing a strange problem. In viewDidLoad

I had written a code like this

self.navigationController.navigationBar.backgroundColor= [UIColor colorWithRed:189.0/255.0 green:105.0/255 blue:105.0/255 alpha:1.0];

this is working fine and changed the navigation bar background color, the problem is in the top of the navigation bar there is white bar showing (that has Carrier, Battery, time), I want that background color also changed... so I tried the below code

[[UINavigationBar appearance] setBackgroundColor:[UIColor colorWithRed:189.0/255.0 green:105.0/255 blue:105.0/255 alpha:1.0]];

But nothing changed, it is showing same white background color, I would like to know whats the mistake I am doing

like image 804
Subramanian Raj Avatar asked Mar 12 '15 14:03

Subramanian Raj


1 Answers

Try this,

[[UINavigationBar appearance] setBarTintColor:[UIColor yellowColor]];

or

self.navigationController.navigationBar.barTintColor = [UIColor blueColor];
self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
self.navigationController.navigationBar.translucent = NO;

and

[self.navigationController.navigationBar setBarStyle:UIStatusBarStyleLightContent];
like image 159
Hiren Varu Avatar answered Sep 21 '22 06:09

Hiren Varu