IOS7 Hide Status bar State Bar

Source: Internet
Author: User

If you are simply hiding the status bar, then by default, you only need to re-implement two new methods

- (Uistatusbarstyle) preferredstatusbarstyle{    return  uistatusbarstylelightcontent;     // uistatusbarstyledefault = 0 Black text, used  when light background // uistatusbarstylelightcontent = 1 white text, used when dark background }- (BOOL) prefersstatusbarhidden{    return// return no indicates to be displayed, Return yes to Hiden}

The previous callback method returns the style when the status bar is displayed, and the following callback controls whether the status bar is displayed.

Calling the following line of code will trigger the callback above

[Self setneedsstatusbarappearanceupdate];

If you want to have a little animation between hiden/show, use the following code:

[UIView animatewithduration:0.5 animations:^{        [self setneedsstatusbarappearanceupdate];    }];

or call the following code:

[[UIApplication sharedapplication] Setstatusbarhidden:yes withanimation:uistatusbaranimationslide];

Another way is to add key:uiviewcontrollerbasedstatusbarappearance to the Infor.plist and set its value to No, which tells the system that the status Bar does not depend on Uiviewcontroller. This allows you to hiden the status bar using the above method.

In setting these, we will still find some problems, that is, although the status bar is not, but instead of a black area, so we also need to adjust the Uiviewcontroller view, the code is:

-(void) viewdidlayoutsubviews{    = self.view.bounds;     20.0 ;     =-topbaroffset;     = viewbounds;    [[UIApplication sharedapplication] setstatusbarstyle:uistatusbarstylelightcontent]; // For status bar style}

Transferred from: http://blog.csdn.net/dqjyong/article/details/17896145

IOS7 Hide Status bar State Bar

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.