Status Bar-ios State Bar

Source: Internet
Author: User

(a) Set the status bar to show and hide 1. Add fields via Info.plist file, control status bar global display and hide
    • Add field in Info.plist file status bar is initially hidden set to YES, the app hides the status bar on the Launchscreen page
    • In the Info.plist file add field View controller-based status bar appearance set to YES, the app default all pages will display the status bar
2, through the code, control the status bar global display and hide
    • The Code settings status bar does not work when the Info.plist file View controller-based status bar appearance is set to No.
    • Add code in APPDELEGATE.M [[UIApplication sharedapplication] setstatusbarhidden:no];
3, through the code, control the status bar local display and hide
    • In Info.plist file View controller-based status bar appearance set to YES
    • Rewrite the notation in the VC that needs to hide the status bar-(BOOL) Prefersstatusbarhidden {return yes;}, return Yes
(b) Set the status bar color1. Set the color of the text part of the status bar
    • Global text color: Add key value in Info.plist Status bar Style,value can set Uistatusbarstyledefault (default black) and Uistatusbarstylelightcontent (white).
    • Global text color: When the Info.plist file View controller-based status bar appearance is set to No, and 2 lines of code are added to APPDELEGATE.M [[UIApplication Shared   Application] Setstatusbarhidden:no]; [[UIApplication sharedapplication] setstatusbarstyle:uistatusbarstylelightcontent]; Can! Note: The value for the key added in Info.plist must be no, and if yes, the code will not work.
    • Local text color: 2 Different cases of this disposition
            first set in Info.plist file  view controller-based status bar appearance  set to YE s           a. Viewcontroller not nested in Uinavigationcontroller, you need to set the following                 Rewrite Uiviewcontroller method  -(Uistatusbarstyle) Preferredstatusbarstyle {return uistatusbarstyledefault;}             B. Viewcontroller for  uinavigationcontroller ROOTVC, you need to set the following                 inherit  uinavigationcontroller write a subclass, and then override the method:                 -(Uistatusbarstyle) Preferredstatusbarstyle {                        return self.topviewcontroller.preferredstatusbarstyle;                 }  for the above status bar display and hide, text or background color are pro-test, if there is a problem, please leave a message @ me!

Status bar of Bar-ios

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.