IOS Modify status bar font Color (pro-test, easy to use)

Source: Internet
Author: User

Sometimes we need to change the color of the status bar font based on different backgrounds, my method is more complicated, if there is a better way to welcome everyone to propose, I will continue to update.
#方法一
1. First, set the Info.plist file:
Set the value of view controller-based status bar appearance to No.
2. In the APPDELEGATE.M method, the following settings, the default will be shown black equals to your app status bar set a main color


-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchOptions {
Set the global status bar font color to black
[UIApplication sharedapplication].statusbarstyle = Uistatusbarstyledefault;
Set global status bar font color to white
[UIApplication sharedapplication].statusbarstyle = uistatusbarstylelightcontent;

return YES;
}

3. Add the following code where it needs to be set to white:

[UIApplication sharedapplication].statusbarstyle = uistatusbarstylelightcontent;

4. Add the following code where you need to change back to black:

[UIApplication sharedapplication].statusbarstyle = Uistatusbarstyledefault;


For example, you want to set the font color of a controller's status bar to the white code as follows:

#pragma mark-Set the status bar color
-(void) Viewwillappear: (BOOL) animated{
[Super viewwillappear:animated];
[UIApplication sharedapplication].statusbarstyle = uistatusbarstylelightcontent;


}

-(void) Viewwilldisappear: (BOOL) animated

{

[Super viewwilldisappear:animated];

[UIApplication sharedapplication].statusbarstyle = Uistatusbarstyledefault;

}


It is important to note that in Uitabbarcontroller, if each page of the tab is loaded, the Viewwillappear method of the next page is called when you switch the page, and then the Viewwilldisappear method of this page is called. Affects the font color change in the status bar.

IOS Modify status bar font Color (pro-test, easy to use)

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.