1、首先在Info.plist上添加
键值:View controller-based status bar appearance 参数为: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]替换就可以了