3 回答

TA貢獻1873條經驗 獲得超9個贊
將以下代碼添加到您的視圖控制器:
if ([self respondsToSelector:@selector(setNeedsStatusBarAppearanceUpdate)]) {
// iOS 7
[self performSelector:@selector(setNeedsStatusBarAppearanceUpdate)];
} else {
// iOS 6
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationSlide];
}
- (BOOL)prefersStatusBarHidden {
return YES;
}

TA貢獻1993條經驗 獲得超6個贊
您需要將此代碼添加到您的AppDelegate文件中,而不是您的Root View Controller中。
或添加屬性狀態欄最初隱藏在您的plist文件中
在iOS 7及更高版本中使用民間語言
請將其添加到您的info.plist文件中,這將有所不同:)
UIStatusBarHidden UIViewControllerBasedStatusBarAppearance
對于iOS 11.4+和Xcode 9.4 +
在一個或所有視圖控制器中使用此代碼
覆蓋var preferredsStatusBarHidden:Bool {return true}

TA貢獻2065條經驗 獲得超14個贊
在iOS 7中,狀態欄的外觀取決于UIViewController默認情況。要全局隱藏狀態欄,請在key 中info.plist使用NOvalue,UIViewControllerBasedStatusBarAppearance并使用value UIApplication的setStatusBarHidden方法YES BOOL。
- 3 回答
- 0 關注
- 902 瀏覽
添加回答
舉報