With the arrival of iOS 13 statusBar's view is no longer accessible trough:
value(forKey: "statusBar") as? UIView
Due to:
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.'
But it's not clear how it should be used for changing colours as keyWindow?.windowScene?.statusBarManager
does not appear to contain anything related to it.
I'm compiling my code with (iOS 10, *) compatibility, so I intend to continue using UIKit.
Any ideas regarding this subject?
this is an ObjC version of most voted answer for those like me who are still using it:
create a category of UIApplication and add it to your project:
This worked for me in Swift 5
This is the best answer I have ever seen.. Cheers
You can add some conditions or use first one. Just create some extension for UIApplication.
UPDATED: Sorry, I don't have enough time to test it in real projects, but it works in "Hello world" app. You can read more info about keyWindow and statusBarFrame in order to make it better.
I have encountered this issue before. My application got crash while I run this code using XCode 11 and Swift 5.0.
Previous Code:-
Just Changed to:-
Now my problem solved. Happy coding.