iOS Development-Disable the view controller to automatically adjust the style of the status bar

Source: Internet
Author: User

One problem with today's project is that when you click the button provided by a third-party library, the effect of the animation makes the status bar font color automatically black, but the status bar has a black background, so it looks like the status bar disappears, but the button is the content in the third-party library. , cannot be modified, what I think here is to prohibit the automatic change of font color in status bar. The specific implementation is as follows:

1. Add a new key:uiviewcontrollerbasedstatusbarappearance in the project's. plist file

2. Set the value of this key to No

3. Add the following line of code to the Didfinishlaunchingwithoptions: method:

Application.statusbarstyle = uistatusbarstylelightcontent;
This way, the status bar will always be white.

This is one way, but there is another way to solve this problem, which is explained in detail in Apple's official Transitionguide.pdf file:

the first method is as stated in the first paragraph:

A good way to dynamically change the system status bar is to override the Preferredstatusbarstyle method, update the appearance of the status bar with an animation module, and call the Setneedsstatusbarappearanceupdate method.

The second method is for me, which is what the note says:

Does not allow the view controller to automatically adjust the style of the status bar, You need to add the Uiviewcontrollerbasedstatusbarappearance key to the Info.plist file and set its value to No, and then call the Uiapplicationstatusbarstyle method to set its style.

iOS Development-Disable the view controller to automatically adjust the style of the status bar

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.