I am rewriting code that was created in the old environment to work in the new environment.
The following code gives a warning.
AppDelegate.swift
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UIApplication.shared.statusBarStyle = .default
return true
}
}
The warning message is as follows:
'statusBarStyle' was deprecated in iOS 13.0: Use the statusBarManager property of the window scene instead.
How can I get rid of this warning?
I tried to rewrite the following code, but I get an error.
UIApplication.shared.statusBarManager = .default
Error details are as follows
Type 'Any' has no member 'default'
For current view in ViewController use
view.window?.windowScene?.statusBarManager?.statusBarStyle = .default
Alternatively, you can find current active window and change its style
let window = UIApplication.shared.windows.filter {$0.isKeyWindow}.first
window?.windowScene?.statusBarManager?.statusBarStyle = .default
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.