You can add an extension for the UIViewController. In Swift:
extension UIViewController { var window : UIWindow { return UIApplication.shared.windows.first! } }
Now you can access it from any view controller. For instance:
override func viewDidLoad() { super.viewDidLoad() self.window.tintColor = .orange }
Allegedly, you should have a window, so you can safely force the window to expand, however you can just make it optional if you do something else with your window hierarchy:
extension UIViewController { var window : UIWindow? { return UIApplication.shared.windows.first } }
Implementation using options:
override func viewDidLoad() { super.viewDidLoad() if let window = self.window { window.tintColor = .orange } }
source share