I want to style the look of my AlertController in the app using appearance. It works well for the background and the buttons, but no matter what I try, the labels for title and message always stay black.
Here is what I am doing:
UIView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).tintColor = .orange
UIVisualEffectView.appearance(whenContainedInInstancesOf: [UIAlertController.self]).effect = UIBlurEffect(style: .dark)
UILabel.appearance(whenContainedInInstancesOf: [UIAlertController.self]).textColor = .white
This is the result I get:
Any ideas, how I can set the color of title and message, or why changing the appearance of UILabel does not work in this case?
The simplest approach is: don't.
There is absolutely no need for you to feel confined to the use of UIAlertController and its simple default view appearance and content. It is nothing but a presented view controller, after all. That means that you can write your own presented view controller that looks and behaves almost like a UIAlertController and its view, except now you are in total charge of its content!
It is far better, easier, and more reliable to write your own alert-like presented view controller than to try to hack into UIAlertController's view; the former is totally legal, while the latter, aside from being unreliable, can get your app barred from the App Store.