千金也難買文字變色的alert view

alert view主要有五種元素所組成,title,message和三種樣式的按鈕,Default,Destructive和Cancel。

不過alert view可是很忠於自己本色,除了Default和Cancel樣式的按鈕稍微容易變心變色之外,其它元素可是千金萬兩也無法令它們變節變色的!

Default和Cancel樣式的按鈕可經由設定UIAlertController view的tintColor改變顏色,例如以下例子裡的alertController.view.tintColor = UIColor.grayColor():

let alertController = UIAlertController(title: “百萬有獎徵答”, message: “簡簡單單的演唱者是?”, preferredStyle: UIAlertControllerStyle.Alert)
alertController.view.tintColor = UIColor.grayColor()
var butAction = UIAlertAction(title: “林俊傑”, style: UIAlertActionStyle.Default, handler:nil)
alertController.addAction(butAction)
butAction = UIAlertAction(title: “張信哲”, style: UIAlertActionStyle.Default, handler:nil)
alertController.addAction(butAction)
butAction = UIAlertAction(title: “放棄”, style: UIAlertActionStyle.Cancel, handler:nil)
alertController.addAction(butAction)
butAction = UIAlertAction(title: “不想回答”, style: UIAlertActionStyle.Destructive, handler:nil)
alertController.addAction(butAction)
self.presentViewController(alertController, animated: true, completion: nil)