Hide the status bar for iOS

Source: Internet
Author: User

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.

Related Article

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.