las*_*302 2 ios swift uialertcontroller
我有一个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)
Run Code Online (Sandbox Code Playgroud)
尝试使用UIAlertActionStyle.Destructive.
let logoutActionSheetButton=UIAlertAction(title: "Logout from App", style: UIAlertActionStyle.Destructive) { ... }
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
674 次 |
| 最近记录: |