Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIAlertAction change color [duplicate]

How can one change the color of a UIAlertAction button, that has been added to an UIAlertController?

like image 797
borchero Avatar asked Dec 15 '14 12:12

borchero


2 Answers

No need to do some complicated things, you only need to change the tintColor property of the UIAlertController main view like this :

let alert = UIAlertController(title: "Title", message: "Some message", preferredStyle: .Alert)
alert.view.tintColor = UIColor.redColor()
let action = UIAlertAction(title: "Ok", style: .Default, handler: nil)
alert.addAction(action)

This way your buttons tint will be red (or whatever color you want)

like image 192
Sylver Avatar answered Nov 06 '22 18:11

Sylver


Refer following post:

Change Text Color of Items in UIActionSheet - iOS 8

Although it's related to changing color of UIActionSheet items but one user has answered according to change color of UIAlertAction items.

like image 24
Salman Zaidi Avatar answered Nov 06 '22 16:11

Salman Zaidi