Global page status bar style white light
Before the project is the global white status bar style, you can add the following options in the Plist file, and then write a code in the base controller to achieve the status of the global status bar white.
[[UIApplication sharedapplication] setstatusbarstyle:uistatusbarstylelightcontent];
partial page status bar style white light
After IOS 7, Uiviewcontroller has a new approach:-Preferredstatusbarstyle, which allows the user to specify the status bar style.
But I tried it, but it didn't work. Later we know why: This method works only if the Viewcontroller is not included in the Uinavigationcontroller. In most cases, Viewcontroller will not be used alone and will generally be nested in Uinavigationcontroller.
So you can write a uinavigationcontroller extension that overrides its default implementation and returns the top Viewcontroller Preferredstatusbarstyle.
Oc
Uinavigationcontroller+statusbar.h
#import <UIKit/UIKit.h>
@interface Uinavigationcontroller ( StatusBar)
-(Uistatusbarstyle) Preferredstatusbarstyle;
@end
//uinavigationcontroller+statusbar.m
#import "Uinavigationcontroller+statusbar.h"
@ Implementation Uinavigationcontroller (StatusBar)
-(Uistatusbarstyle) Preferredstatusbarstyle {return
[ Self Topviewcontroller] preferredstatusbarstyle];
}
@end
Swift
Extension Uinavigationcontroller {
override public func Preferredstatusbarstyle ()-> Uistatusbarstyle {
Return Self.topViewController.preferredStatusBarStyle ()
}
Then where do I need to introduce the Uinavigationcontroller+statusbar.h header file, this time the Preferredstatusbarstyle works. If you use Swift, add the extension and you are done.
Reference address