I used to have the below code but after upgrading to iOS 13, I have got the error below:
UIApplication.shared.statusBarView?.backgroundColor = UIColor(red: 94/225, green: 64/255, blue:204/255, alpha: 1.0)
App called -statusBar or -statusBarWindow on UIApplication: this code must be changed as there's no longer a status bar or status bar window. Use the statusBarManager object on the window scene instead.'
How could the background color of status bar be set now?
The warning message mention about using statusBarManager and so I did something like this, yet I could not get it to work.
var statusBar = UIView()
if #available(iOS 13.0, *) {
statusBar = UIView(frame: UIApplication.shared.keyWindow?.windowScene?.statusBarManager?.statusBarFrame ?? CGRect.zero)
statusBar.backgroundColor = UIColor.red
UIApplication.shared.keyWindow?.addSubview(statusBar)
} else {
//ios 12 and below
UIApplication.shared.statusBarView?.backgroundColor = UIColor(red: 94/225, green: 64/255, blue:204/255, alpha: 1.0)
}
statusBarManager
? – vpoltave