UIAlertAction改变颜色

时间:2014-12-15 12:58:56

标签: ios uialertcontroller

如何更改已添加到UIAlertAction的{​​{1}}按钮的颜色?

2 个答案:

答案 0 :(得分:8)

不需要做一些复杂的事情,你只需要改变UIAlertController主视图的tintColor属性,如下所示:

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)

这样你的按钮色调将是红色(或你想要的任何颜色)

答案 1 :(得分:3)

请参阅以下帖子:

Change Text Color of Items in UIActionSheet - iOS 8

虽然它与更改UIActionSheet项目的颜色有关,但有一位用户根据UIAlertAction项目的更改颜色进行了回答。

相关问题