2015-11-03 24 views
0

我使用ios 9 swift 2,我想更改警報的按鈕色調顏色。這是正常工作的代碼:tlickcolor的警報將在klick後發生變化

  let alertController = UIAlertController(title: „Title here", message: „Text here.", preferredStyle: .Alert) 

     let rateAction = UIAlertAction(title: "Button 1", style: .Default) { (action) in 
      print(„OK「) 
     } 

     let cancelAction = UIAlertAction(title: "Button 2", style: .Default) { (action) in 
      print(„Cancel") 
     } 

     alertController.addAction(rateAction) 
     alertController.addAction(cancelAction) 
     self.presentViewController(alertController, animated: true) {} 
     alertController.view.tintColor = UIColor(red: (122/255.0), green: (165/255.0), blue: (23/255.0), alpha: 1.0) 
    } 

enter image description here

,但如果我認爲我的手指上的一個按鈕,就可以看到,該tintcolor更改默認:

enter image description here

任何想法如何我可以解決這個問題?

回答

0

試試這個:

your_btn.setTitleColor(UIColor.brownColor(), forState: UIControlState.Highlighted) 

此外,您還可以設置RGBA的UIColor:

UIColor(red: 255/255, green: 255/255, blue: 255/255, alpha: 1)