![](/img/trans.png)
[英]Change Alertview UIAlertController Buttons and Title color in iOS
[英]Change the color of one or specific buttons on UIAlertController in Swift
我有一个UIController的操作表类型,其中显示两个项目,第一个是“从App注销”,另一个是“取消”。 我想将显示“从应用程序注销”的按钮的字体颜色更改为红色,并将“取消”按钮保留为默认颜色。 我怎样才能做到这一点? 下面是我的代码:
let cancelActionSheetButton = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel) {
(cancelSelected) -> Void in
print("Cancel Selected")
}
let logoutActionSheet = UIAlertController(title:"Logout", message: nil, preferredStyle: UIAlertControllerStyle.ActionSheet)
let logoutActionSheetButton = UIAlertAction(title: "Logout from App", style: UIAlertActionStyle.Default) {
(logoutSelected) -> Void in
}
logoutActionSheet.addAction(logoutActionSheetButton)
logoutActionSheet.addAction(cancelActionSheetButton)
self.presentViewController(logoutActionSheet, animated: true, completion:nil)
尝试使用UIAlertActionStyle.Destructive
。
let logoutActionSheetButton=UIAlertAction(title: "Logout from App", style: UIAlertActionStyle.Destructive) { ... }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.