How can I get the default iOS red warning color that is used in UIAlertAction
with style UIAlertActionStyle.Destructive
without composing the color myself?
There is no API that will allow you to access the color at runtime without creating a UIAlertAction
.
I know it's not exactly what you wanted, but you can do something like this:
extension UIColor {
class func destructiveColor() -> UIColor {
return UIColor(red: 1, green: 0.2196078431, blue: 0.137254902, alpha: 1)
}
}
Usage:
let redColor = UIColor.redColor()
let destructiveColor = UIColor.destructiveColor()
Note that the two reds are slightly different:
Of course, this solution is imperfect because it will not automatically update if Apple tweaks the color.