Status Bar Text Color iOS 7 [duplicate]

I am unable to change the text colour in the status bar in iOS 7 SDK. Currently its black and i want it to be white for all my view controllers in a storyboard.

I have seen few questions on StackOverflow like THIS, THIS and THIS but they didn't of much help. Also may be due to the fact that i am unable to find UIViewControllerBasedStatusBarAppearance to YES in my plist file.

Can any one tell me the right way to set the status bar text colour to white for all view controllers in the storyboard? Thanks in advance!


Solution 1:

Let me give you a complete answer to your question. Changing the status bar text colour is very easy but its a little confusing in iOS 7 specially for newbies.

If you are trying to change the colour from black to white in StoryBoard by selecting the view controller and going to Simulated Metrics on the right side, it won't work and i don't know why. It should work by changing like this but any how.

Secondly, you won't find UIViewControllerBasedStatusBarAppearance property in your plist but by default its not there. You have to add it by yourself by clicking on the + button and then set it to NO.

ios 7 status bar text color

Lastly, you have to go to your AppDelegate.m file and add the following in didFinishLaunchingWithOptions method, add the following line:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

This will change the colour to white for all your view controllers. Hope this helps!

Solution 2:

If you're looking for UIViewControllerBasedStatusBarAppearance, you'll need to click the little plus sign that appear when you hover over the root element in your plist file.

plist file

Once you do that, a new row will appear - select "View controller-based status bar appearance" from the dropdown list and set NO as its value. (That friendly name is declared internally as UIViewControllerBasedStatusBarAppearance)

Next, calling the following method in your app delegate should set the status bar color to white for all view controllers:

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];

Solution 3:

Set the UIViewControllerBasedStatusBarAppearance to YES in the plist

In viewDidLoad do a [self setNeedsStatusBarAppearanceUpdate];

Add the following method:

-(UIStatusBarStyle)preferredStatusBarStyle{ 
    return UIStatusBarStyleLightContent; 
}

Solution 4:

It is YES by default, so you won't see it. You need to add

UIViewControllerBasedStatusBarAppearance

to your plist and set it to NO.

Then you can call

[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];