Settings for iOS status bar (Uistatusbar)

Source: Internet
Author: User

Uistatusbar is the status bar that displays battery and time information at the top of the app, with a width equal to the screen width and a height of 20. The display control of it is divided into two cases, one is when the program starts and the other is when the program is running. 
  

1. When the program starts.

    • In Info.plist, the value corresponding to the status bar is initially hidden (Uistatusbarhidden) is set to Yes, hidden when the program starts, and otherwise displayed. If you want to change its font color, set the value for status bar style (Uistatusbarstyle) to the type you want in info (uistatusbarstyelightcontent. )。

2. When the program runs

    • Also in two cases, call it effects A and B bar, A is your view controller's status bar display is controllable, but the style is not controllable (all view controller's status bar is a style). b is you can control the display and style of each status bar. Add a key value to the Info.plist file: View controller-based status bar appearance, which means that each controller controls its own status bar individually.
    • If you want a effect, set the view controller-based status bar appearance value to No, and then add the following code to the view controller to control whether the display is displayed or not.

[[UIApplication sharedapplication] Setstatusbarhidden:yes Withanimation:uistatusbaranimationfade];

    • Implementing the B effect requires setting the view controller-based status bar appearance value to Yes, and then rewriting the following methods in the view controller that you want to control the status bar to display:

      Whether to display the status bar
      -(BOOL) prefersstatusbarhidden{
      return NO;
      }
      Style of the status bar
      -(Uistatusbarstyle) preferredstatusbarstyle{
      return uistatusbarstylelightcontent;

      }

Off-topic: If your view controller contains a Uinavigationbar, when you choose to hide the status bar, Uinavigationbar will appear unhealthy and the height from 64 to 44, the solution to this problem will be updated later.

Settings for iOS status bar (Uistatusbar)

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.