How can I change the color of the UIAlertView
button title.
I want title Ok
in red color.
The Travis Weerts answer should work if you are using a UIAlertController
. For those using UIAlertView
, you can use the UIView
appearance settings.
You can aim the alerts component this way on iOS < 9 :
[[UIView appearanceWhenContainedIn:[UIAlertView class], nil] setTintColor:[UIColor redColor]];
[[UIView appearanceWhenContainedIn:[UIAlertController class], nil] setTintColor:[UIColor redColor]];
And on iOS 9 :
[[UIView appearanceWhenContainedInInstancesOfClasses:@[[UIAlertView class]]] setTintColor:[UIColor redColor]];
[[UIView appearanceWhenContainedInInstancesOfClasses:@[[UIAlertController class]]] setTintColor:[UIColor redColor]];
Actually, you can change the tint color of the view of the UIAlertController in iOS8.
UIAlertController *alertController = ....
[alertController.view setTintColor:[UIColor greenColor]];
for Swift 3, use:
alertController.view.tintColor = UIColor.red
AFTER you present your alert controller
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With