How to change Status Bar text color in iOS 7
My application has a dark background, but in iOS 7 the status bar became transparent. So I can't see anything there, only the green battery indicator in the corner. How can I change the status bar text color to white like it is on the home screen?
Set the UIViewControllerBasedStatusBarAppearance
to YES
in the .plist file.
In the viewDidLoad
do a [self setNeedsStatusBarAppearanceUpdate];
Add the following method:
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
Note : This does not work for controllers inside UINavigationController
, please see Tyson's comment below :)
Swift 3 - This will work controllers inside UINavigationController
. Add this code inside your controller.
// Preferred status bar style lightContent to use on dark background.
// Swift 3
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
Alternatively, you can opt out of the view-controller based status bar appearance:
View controller-based status bar appearance
to NO
in your Info.plist
. [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
Note: This method has been deprecated in iOS9. Use preferredStatusBarStyle
on the UIViewController instead. (see Apple Developer Library)
You can do this without writing any line of code!
Do the following to make the status bar text color white through the whole app
On you project plist file:
Transparent black style (alpha of 0.5)
NO
NO
上一篇: Corona SDK与Graphic 2.0的位置不起作用
下一篇: 如何更改iOS 7中的状态栏文字颜色