IOS-status bar font color [White] [Xcode9.1], ios-xcode9.1
Before Xcode9
To set the status bar color, first add UIViewControllerBasedStatusBarAppearance = false to the info. plist file;
<key>UIViewControllerBasedStatusBarAppearance</key> <false/>
Add the following code to the delegate didfinishlaunchingwitexceptions method;
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent animated:YES];[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
After Xcode9
Xcode9.1 when I set the font of the status bar to white, the above method does not work. I collected a circle and found the result;
Also in info. plist, add UIViewControllerBasedStatusBarAppearance = true. Note that it is true;
<key>UIViewControllerBasedStatusBarAppearance</key><true/>
Create a class BaseNavigationController Based on UINavigationController and a class BaseViewController Based on UIViewController;
BaseNavigationController. m
-(UIViewController *)childViewControllerForStatusBarStyle { return self.topViewController;}-(UIViewController *)childViewControllerForStatusBarHidden { return self.topViewController;}
BaseViewController. m
-(UIStatusBarStyle) preferredStatusBarStyle {// set the white return UIStatusBarStyleLightContent here ;}
-(BOOL) prefersStatusBarHidden {return NO ;}
In the project, if you create a UINavigationController, The BaseNavigationController is inherited. When you create a UIViewController, The BaseViewController is inherited. In this way, you can change the font of the status bar. If you are an existing project, you can expand the uinavig,;