Set UILabel color in alertController

I have an alertController that is presented as popover on iPad

let alertController = UIAlertController(title: alertTitle, message: alertMessage, preferredStyle: alertStyle)

if let ppc = alertController.popoverPresentationController {
  // …
}

Is it possible to change the message font color (which is really very light on iPad) ?

It is OK on iPhone with the same alert (not popover): text is much more readable:

Answered by Claude31 in 825345022

Changing the tintColor only changes color of active buttons, not message or title text.

The best I found is to change the ppc backgroundColor to get a better contrast.

Slight improvement with a very light gray:

            if let ppc = alertController.popoverPresentationController { 
                ppc.sourceView = aButton as UIView
                ppc.sourceRect = (aButton as UIView).bounds
                if UIScreen.main.traitCollection.userInterfaceStyle == .dark { 
                    ppc.backgroundColor = UIColor(red: 0.01, green: 0.01, blue: 0.01, alpha: 1.0)
                } else {
                    ppc.backgroundColor =  UIColor(red: 0.99, green: 0.99, blue: 0.99, alpha: 1.0)
                }
            }
Accepted Answer

Changing the tintColor only changes color of active buttons, not message or title text.

The best I found is to change the ppc backgroundColor to get a better contrast.

Slight improvement with a very light gray:

            if let ppc = alertController.popoverPresentationController { 
                ppc.sourceView = aButton as UIView
                ppc.sourceRect = (aButton as UIView).bounds
                if UIScreen.main.traitCollection.userInterfaceStyle == .dark { 
                    ppc.backgroundColor = UIColor(red: 0.01, green: 0.01, blue: 0.01, alpha: 1.0)
                } else {
                    ppc.backgroundColor =  UIColor(red: 0.99, green: 0.99, blue: 0.99, alpha: 1.0)
                }
            }
Set UILabel color in alertController
 
 
Q