swift 设置状态栏样式不起作用

不起作用代码:

override var preferredStatusBarStyle: UIStatusBarStyle{
        return .lightContent
    }

解决办法:
在info.plist 添加key:View controller-based status bar appearance 设置为NO
再设置属性

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOpt
[UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    application.statusBarStyle = .lightContent
    return true
}

你可能感兴趣的:(swift)