iOS_隱藏頂部狀態欄
阿新 • • 發佈:2017-05-14
iss tor 方式 實現 sets p s 隱藏 board ret
iOS 6
在 Info.plist 中添加 Status bar is initially hidden 一行,選擇值為 YES。
iOS 7
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
iOS 6
在 Info.plist 中添加 Status bar is initially hidden 一行,選擇值為 YES。
iOS 7
不但要在 Info.plist 中添加 Status bar is initially hidden一行,選擇值為 YES,
還需添加 View controller-based status bar appearance 一行,選擇值為 NO。
iOS_隱藏頂部狀態欄