I have an action sheet type of UIController which shows two items, the first one is "Logout from App" and the other one is "Cancel". I want to change the font color of the button which shows "Logout from App" to red and leave the "Cancel" button with default color. How can I do that? Below is my code:
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) { ... }
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.