(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