Changing the tintColor
of the UIAlertController
s used to be possible to change via the window
's tintColor
. This was usually done in the AppDelegate
and it would affect UIAlertController
s tintColor as well. Unfortunately in projects started with Xcode 11 for iOS SDK 13 there is no window in the AppDelegate
anymore.
Where do I need to set the tintColor
, so that all UIAlertController
s use it?
Things I tried:
tintColor
of the first UIViewController
's .view.window
. Unfortunately the window
is nil
.globalTint
color. This affects the navigation bars and is also inherited by other UI elements, but not by the UIAlertController.Thank you for your help!
Try this to get access to the window using windowScene
for iOS 13+:
let windowScene = UIApplication.shared
.connectedScenes
.filter { $0.activationState == .foregroundActive }
.first
if let windowScene = windowScene as? UIWindowScene {
window = UIWindow(windowScene: windowScene) // now you've access to the window
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.