Running an app in iOS7 initially designed for previous versions, a dark grey navigation bar tints the status bar whose text is black.
I'm trying to adapt it to the newest version, and I'm setting the UIApplication.statusBarStyle to UIStatusBarStyleLightContent like this:
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
This piece of code should change the status bar text colour to white but it doesn't. I put a watchpoint in the _statusBarRequestedStyle property of my UIApplication instance and I could see that this is set to 0 (UIStatusBarStyleDefault) by some call from UIApplicationMain between the execution of viewWillAppear and viewDidAppear methods.
I can't figure out what/why the status bar style is changed at this point and I would appreciate any advice if you have experienced the same.
Thanks in advance!
EDIT: From iOS 7 UI Transition Guide (https://developer.apple.com/library/ios/documentation/userexperience/conceptual/TransitionGuide/Bars.html)
In iOS 7, you can control the style of the status bar from an individual view controller and change it while the app runs. If you prefer to opt out of this behavior and set the status bar style by using the UIApplication statusBarStyle method, add the UIViewControllerBasedStatusBarAppearance key to an app’s Info.plist file and give it the value NO.
Option 1:
1) if your app is View controller-based then you have to set it app.plist file like this:
UIViewControllerBasedStatusBarAppearance=NO;
2) you have to set this method in each controller:
-(UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
Option 2:
Write this single line in AppDelegate.m file in application didFinishLaunchingWithOptions: method
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];
May be it will help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With