13
votes

I tried several solutions from SO for this problem but none of them worked for me. I created a new iOS7 project with one simple view. I tried setting

View controller-based status bar appearance to NO

and in AppDelegate:

[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:NO];

However this removes the status bar completely.

Without the View controller-based status bar appearance option, Regardless what I set for Status bar style in the plist file, the status bar text is still black. I need it to be white for the entire application. Is this possible?

I am on latest xcode version.

4
This happened to me and I fixed it by setting the Status bar is initially hidden to NO in the info.plist additionally to the 2 steps you commentedChuy47

4 Answers

38
votes

did you try it without "Animated:No" ?

Go to Info tab of the project target, Add Row:

UIViewControllerBasedStatusBarAppearance, set value NO

Then in appdelegate.m

- (BOOL)application:(UIApplication *)application 
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{

[application setStatusBarStyle:UIStatusBarStyleLightContent];
}

This should set it application wide.

27
votes

The Accepted answer seemed to work sometimes. I found out that the UIViewController can change the status bar style also. To get around this and always work, cause I didn't need the UIViewControllers controlling the status bar, I had to set UIViewControllerBasedStatusBarAppearance to NO in my Info.plist

21
votes

Use needsStatusBarAppearanceUpdate to update status bar in viewDidLoad: method of view controller

[self setNeedsStatusBarAppearanceUpdate];

Now add below method into view controller:

- (UIStatusBarStyle) preferredStatusBarStyle {
    return UIStatusBarStyleLightContent;
}
3
votes

I would go with Logan's answer. As of iOS 9, UIApplication's setStatusBarStyle: method is deprecated anyway, so you'll want to start moving away from using that. The preferred method, now is to implement preferredStatusBarStyle within your ViewController like Logan has described.