IOS Modify status bar Preferredstatusbarstyle do not perform a problem

Source: Internet
Author: User

First, in the old version of iOS, the status bar is always white style. In iOS 7, we can modify the appearance of the status bar in each view controller. The Uistatusbarstyle constant allows you to specify that the contents of the status bar are dark or bright colors. By default, the status bar displays a dark color. That is, the time on the status bar, the battery indicator, and the Wi-Fi signal are displayed as dark colors. If a dark color is used as the background in the navigation bar, the effect looks as follows:

In this case, we might want to change the style of the navigation bar to bright colors. There are two ways to do this. In iOS 7, we can overriding methods in each view controller preferredStatusBarStyle: , as follows:

-(Uistatusbarstyle) Preferredstatusbarstyle {         return uistatusbarstylelightcontent;}

PS: This method is only called if the following code is set ( for Preferredstatusbarstyle does not perform a problem ):

[Self.navigationController.navigationBar Setbarstyle:uibarstyleblack];

The effect of the above code is as follows:

Second, in iOS 7, the above method to modify the status bar style is very good. In addition, we can use UIApplication's Statusbarstyle method to set the status bar, but first you need to stop using it View controller-based status bar appearance . In the Info tab of Project target, insert a new key with the name View controller-based status bar appearance , and set its value to No.

You can then use the following code to set the status bar style:

[[UIApplication sharedapplication] setstatusbarstyle:uistatusbarstylelightcontent];

  

IOS Modify status bar Preferredstatusbarstyle do not perform a problem

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.