Ios 在Swift中更改UIAlertController上一个或特定按钮的颜色
我有一个UIController的操作表类型,它显示两个项目,第一个是“从应用程序注销”,另一个是“取消”。我想将显示“从应用程序注销”的按钮的字体颜色更改为红色,并将“取消”按钮保留为默认颜色。我该怎么做?下面是我的代码:Ios 在Swift中更改UIAlertController上一个或特定按钮的颜色,ios,swift,uialertcontroller,Ios,Swift,Uialertcontroller,我有一个UIController的操作表类型,它显示两个项目,第一个是“从应用程序注销”,另一个是“取消”。我想将显示“从应用程序注销”的按钮的字体颜色更改为红色,并将“取消”按钮保留为默认颜色。我该怎么做?下面是我的代码: let cancelActionSheetButton = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel) { (cancelSelected) -> Void in
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) { ... }