Before Xcode9
Set the status bar color first in the Info.plist file, add uiviewcontrollerbasedstatusbarappearance = false;
<key>UIViewControllerBasedStatusBarAppearance</key> <false/>
Let's add the following code to the delegate Didfinishlaunchingwithoptions method;
[[UIApplication sharedapplication] setstatusbarstyle:uistatusbarstylelightcontent Animated:YES]; [[UIApplication sharedapplication] Setstatusbarhidden:no Withanimation:uistatusbaranimationfade];
After Xcode9
xcode9.1 I set the status bar when the font is white, according to the above method does not work, collected a circle with the results;
Also in Info.plist, add uiviewcontrollerbasedstatusbarappearance = True, note is true;
<key>UIViewControllerBasedStatusBarAppearance</key><true/>
Then create a new class Basenavigationcontroller based on Uinavigationcontroller, a baseviewcontroller based on Uiviewcontroller class;
Basenavigationcontroller.m
-(Uiviewcontroller *) childviewcontrollerforstatusbarstyle { return Self.topviewcontroller;} -(Uiviewcontroller *) Childviewcontrollerforstatusbarhidden { return Self.topviewcontroller;}
Baseviewcontroller.m
-(Uistatusbarstyle) preferredstatusbarstyle{ /// here set white return uistatusbarstylelightcontent;}
-(BOOL) prefersstatusbarhidden{ return NO;
In the project, if the new Uinavigationcontroller inherits Basenavigationcontroller, the new Uiviewcontroller inherits Baseviewcontroller, This will enable the status bar font to change, if you are already existing projects, you can expand Uinavigationcontroller and Uiviewcontroller, to implement;
ios-status bar Font Color "white" "Xcode9.1"