Info.plist file, theview controller-based status bar appearance key is set to Yes, the view controller pair status The bar's setting priority is higher than the application setting. If no is set to application, the Prefersstatusbarhidden method of view controller is invalid and is not called at all.
1. View controller-based status bar appearance set to Yes.
When the view Controller has a priority setting of status bar higher than the application setting, the status bar is hidden in the following way.
1.1 Call Setneedsstatusbarappearanceupdate in the View controller to update the display of the status bar
1 -(void 2 { 3 [Super viewdidappear:animated]; 5 if
([self respondstoselector: @selector (setneedsstatusbarappearanceupdate)]) { 6 [self Prefersstatusbarhidden]; [self performselector: @selector (setneedsst Atusbarappearanceupdate)]; " 9 }
1.2 The implementation of the Prefersstatusbarhidden that covers the view controller, returns YES.
1 - (BOOL) Prefersstatusbarhidden2{3 return YES; 4 }
2. View controller-based status bar appearance set to No
At this point the application has the highest priority and hides the status bar in the following way:
1 [[uiapplication sharedapplication] Setstatusbarhidden:yes Withanimation:no];
3. Conclusion
- If view controller-based status bar appearance is set to NO,IOS6 and iOS7, the status bar is hidden in the following ways.
1 [[uiapplication sharedapplication] Setstatusbarhidden:yes Withanimation:no];
- If view controller-based status bar appearance is set to Yes, you need to determine whether the current is iOS6 or iOS7.
If it is iOS6, it is also hidden through sharedapplication.
If it is iOS7, hide the status bar in a setneedsstatusbarappearanceupdate plus prefersstatusbarhidden way.
4. Take the settings in the View controller-based status bar appearance in Info.plist
1 nsnumber *isvcbasedstatusbarappearancenum = [[NSBundle mainbundle]objectforinfodictionarykey:@ " uiviewcontrollerbasedstatusbarappearance " ]; 2 if (isvcbasedstatusbarappearancenum) { 3 _isvcbasedstatusbarappearance = Isvcbasedstatusbarappearancenum.boolvalue; 4 Else { 5 // default 6 }