【发布时间】:2015-06-01 05:27:36
【问题描述】:
我想将 UIAlertController 中“取消”按钮的颜色更改为橙色,并保持“注销”按钮的颜色不变。我附上了下面的警报控制器的屏幕截图和代码。
警报视图的代码
alert = UIAlertController(title: "", message: "Are you sure you want to log out?", preferredStyle: UIAlertControllerStyle.Alert)
alert.view.tintColor = UIColor.blackColor()
alert.addAction(UIAlertAction(title: "Log out", style: UIAlertActionStyle.Cancel, handler:{ (UIAlertAction)in
println("Log Out button clicked.")
prefs.setBool(false, forKey: "Isloggedin")
NSUserDefaults.resetStandardUserDefaults()
prefs.setBool(true, forKey: "IsEmail")
prefs.setObject(email, forKey: "loggedemail")
prefs.synchronize()
let mainview = self.storyboard?.instantiateViewControllerWithIdentifier("mainscreen") as! mainViewController
self.navigationController?.pushViewController(mainview, animated: true)
}))
//alert.view.tintColor = UIColor.yellowColor()
alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default, handler:{ (UIAlertAction)in
println("Cancel button clicked.")
}))
self.presentViewController(alert, animated: true, completion: {
println("completion block.")
})
【问题讨论】: