我有我的UIAlertController
,首選樣式ActionSheet
可以正常工作,沒有任何問題。爲了防止代碼冗長的牆上,我已經刪除了UIAlertAction
關閉的動作和我添加代碼:UIAlertController(ActionSheet)在設置tintColor後更改形狀
let alert = UIAlertController(title: "More actions", message: nil, preferredStyle: .ActionSheet)
//alert.view.tintColor = UIColor(red: CGFloat(252.0/255.0), green: CGFloat(112.0/255.0), blue: CGFloat(87.0/255.0), alpha: 1.0)
alert.addAction(UIAlertAction(title: "Rename", style: .Default, handler: { (action: UIAlertAction!) -> Void in }))
alert.addAction(UIAlertAction(title: "Move", style: .Default, handler: { (action: UIAlertAction!) -> Void in }))
alert.addAction(UIAlertAction(title: "Keep offline", style: .Default, handler: { (action: UIAlertAction!) -> Void in }))
alert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
此代碼工作正常,並導致成這樣:
然而當我取消註釋我設置tintColor
的行時,我失去了我的.Default
按鈕和.Cancel
按鈕之間的差距:
有沒有辦法來防止這種情況的發生,或者這是否是我忽視的一些微小細節的後果?
奇怪的肯定。問題是,如果您在設置其他按鈕之後設置了色調顏色,默認是否仍然會發生? – Aggressor
我沒有想到這一點。有用! – Michal
雅它愚蠢的,你甚至不得不這樣做,它的蘋果部分 – Aggressor