ios UIAlertAction 改变颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27484657/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
UIAlertAction change color
提问by borchero
How can one change the color of a UIAlertAction
button, that has been added to an UIAlertController
?
如何更改UIAlertAction
已添加到 的按钮的颜色UIAlertController
?
采纳答案by Salman Zaidi
Refer following post:
参考以下帖子:
Change Text Color of Items in UIActionSheet - iOS 8
更改 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.
虽然它与更改UIActionSheet
项目的颜色有关,但一位用户已根据UIAlertAction
项目的更改颜色进行了回答。
回答by Sylver
No need to do some complicated things, you only need to change the tintColor property of the UIAlertController main view like this :
不需要做一些复杂的事情,你只需要像这样更改 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)
This way your buttons tint will be red (or whatever color you want)
这样你的按钮就会变成红色(或者你想要的任何颜色)