IOS-status bar font color [White] [Xcode9.1], ios-xcode9.1

Source: Internet
Author: User

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,;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.