1菇爪、首先在Info.plist上添加
鍵值:View controller-based status bar appearance ?參數(shù)為:NO
圖一
2怖亭、在AppDelegate里面配置
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
? ?UIApplication.shared.setStatusBarHidden(true, with: .none)
? UIApplication.shared.setStatusBarHidden(false, with: .none)
}
UIApplication.shared.setStatusBarHidden(true, with: .none) ?在Xcode 9上次方法廢棄了用[UIViewController prefersStatusBarHidden]替換就可以了