Hide the status bar for iOS
It is not easy to operate the status bar on the top after iOS. The procedure is as follows:
First, add the View controller-based status bar appearance item to the info. plist file,
1. If the View controller-based status bar appearance item is set to YES, View controller has a higher priority than application.
In this case, the priority of the status bar setting in view controller is higher than the application setting. Use the following method to hide the status bar:
1. Call setNeedsStatusBarAppearanceUpdate in view controller to update the status bar display.
-(Void) viewDidAppear :( BOOL) animated {
[Super viewDidAppear: animated];
If ([self respondsToSelector: @ selector (setNeedsStatusBarAppearanceUpdate)]) {
[Self prefersStatusBarHidden];
[Self defined mselector: @ selector (setNeedsStatusBarAppearanceUpdate)];
}
}
2. overwrite the implementation of view controller's prefersstatusbarhid. YES is returned.
-(BOOL) prefersStatusBarHidden
{
Return YES;
}
2. If the View controller-based status bar appearance item is set to NO, the prefersstatusbarhidmethod of the view controller is invalid and will not be called.
1. Use [[UIApplication sharedApplication] setStatusBarHidden: YES withAnimation: NO]; To hide the status bar.
Because it is compatible with multiple system versions, I generally use method 2.