func setStatusBarBackgroundColor(color: UIColor) {
guard let statusBar = UIApplication.shared.value(forKeyPath: "statusBarWindow.statusBar") as? UIView else { return }
statusBar.backgroundColor = color
}
I run this code for status bar background color but at this time My application got crash show the issue in the output console.
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '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.'
'statusBar or -statusBarWindow' was deprecated in iOS 13.0: Use the statusBarManager property of the window scene instead.
Unfortunately Apple deprecated some of the mentioned methods of accessing the status bar and editing its attributes. You will have to use the The StatusBarManager
object of the WindowScene
. The following method works for iOS 13 and above.
if #available(iOS 13.0, *) {
let statusBar = UIView(frame: UIApplication.shared.keyWindow?.windowScene?.statusBarManager?.statusBarFrame ?? CGRect.zero)
statusBar.backgroundColor = UIColor.init(red: 237.0/255.0, green: 85.0/255.0, blue: 61.0/255.0, alpha: 1.0)
UIApplication.shared.keyWindow?.addSubview(statusBar)
} else {
UIApplication.shared.statusBarView?.backgroundColor = UIColor.init(red: 237.0/255.0, green: 85.0/255.0, blue: 61.0/255.0, alpha: 1.0)
}
to achieve this result:Memory Management with ARC and Avoiding retain cycles with Weak and Unowned in Swift.
How to create Certificate Signing Request (CSR) in macOS (iOS) Keychain Access
Swift 5.2 Generics Explained - How to Use Generics in iOS Apps
How to generate .ipa file for In-House and distribute enterprise iOS app inside a company
Creating the iOS Development & Distribution Certificate and .p12 File
Development Xcode11 Import Development and Distribution Provisioning Profile
0 Comments