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

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

Image for post
Image for post

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

Image for post
Image for post

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

let alertController = UIAlertController(title: “百萬有獎徵答”, message: “簡簡單單的演唱者是?”, preferredStyle: UIAlertControllerStyle.Alert)
alertController.view.tintColor = UIColor.grayColor()

彼得潘的iOS App程式設計入門,文組生的iOS App程式設計入門講師,彼得潘的 Swift 程式設計入門,App程式設計入門作者,http://apppeterpan.strikingly.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store