I want to be able to change the status bar background color of my app, to transparent on 3 specific UIViewControllers
and set the rest to be something else.
I'm not sure how to check which view controller is the current view controller. It should be an if/else statement. I have this in my AppDelegate
:
extension UIApplication {
var statusBarView: UIView? {
return value(forKey: "statusBar") as? UIView
}
}
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
{
let appDelegate = UIApplication.shared.delegate as? AppDelegate
if let currentVC = appDelegate?.window?.rootViewController?.getCurrentlyDisplayedVC()
{
if currentVC is LoginVC || currentVC is RegisterVC || currentVC is LostPasswordVC {
UIApplication.shared.statusBarView?.backgroundColor = .clear
} else {
UIApplication.shared.statusBarView?.backgroundColor = Color_Main_Blue
}
}
UIApplication.shared.statusBarStyle = .lightContent
return true
}