Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change status bar color Objective-C

In my app, there is a dark mode, and I would like to know how to change the status bar color? Thanks,

UIColor *color = [UIColor whiteColor];
self.navigationController.navigationBar.barTintColor = color;
like image 931
pilou Avatar asked Feb 21 '17 11:02

pilou


3 Answers

This is what worked for me.

click on navigationBar -> style -> Default Then select Translucent and below that Bar Tint -> (select any colour you want)

like image 160
Narasimha Nallamsetty Avatar answered Sep 24 '22 01:09

Narasimha Nallamsetty


Ok, according to Apple Docs setStatusBarStyle:animated: is deprecated since iOS 9.0, and you should now put this code instead:

-(UIStatusBarStyle)preferredStatusBarStyle 
{
return UIStatusBarStyleLightContent;
}

Good luck and happy coding! :)

like image 20
Joe Razon Avatar answered Sep 24 '22 01:09

Joe Razon


Add these lines in plist

<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
like image 39
Swetha Lakshmi Avatar answered Sep 25 '22 01:09

Swetha Lakshmi