iOS6和iOS7在隐藏 Status Bar 三种方式比较:
Storyboard
界面上选中UIViewController,最右边Simulated Metrics找到 Status Bar 设定成 None
ViewController
iOS 6
通过[UIApplication sharedApplication] 取得app的单例,然后调用setStatusBarHidden方法隐藏 Status Bar。
UIApplication *app = [UIApplication sharedApplication]; [app setStatusBarHidden:YES withAnimation:YES];
iOS 7
实现prefersStatusBarHidden方法,返回 YES- (BOOL)prefersStatusBarHidden { return YES; } //特殊情况时,调用下面方法,强制重新绘製 Status Bar [self setNeedsStatusBarAppearanceUpdate];
Info.plist
不但要在 Info.plist 中增加 Status bar is initially hidden一行,选择值为 YES,
还需增加 View controller-based status bar appearance 一行,选择值为 NO。
原文地址:http://blog.csdn.net/pre_eminent/article/details/38235223