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