简体   繁体   中英

Light status bar style doesn't work for iPhone XS max and XR?

I need to set status bar style on Light for whole App. I set StatusBarStyle on LightContent and View controller-based status bar appearance on No . It works fine for all devices except iPhone XR and iPhone XS max. What did I do wrong? How to set status bar style on Light for whole App?

First thing is that if you want to change the light status bar for the whole app then you need to do code in the app delegate file.

In AppDelegate, one method is there for changing the status bar appearance.

override var preferredStatusBarStyle: UIStatusBarStyle {
    return .lightContent
}

And in didFinishLaunch method, add the following

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.
UINavigationBar.appearance().barStyle = .blackOpaque
return true
}

Hope this will help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM