Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIAlertController change font color

Tags:

Here's my code that creates the UIAlertController

    // Create the alert controller     var alertController = UIAlertController(title: "Are you sure you want to call \(self.number)?", message: "", preferredStyle: .Alert)      // Create the actions     var okAction = UIAlertAction(title: "Call", style: UIAlertActionStyle.Default) {         UIAlertAction in         var url:NSURL = NSURL(string: "tel://\(self.number)")!         UIApplication.sharedApplication().openURL(url)     }      var cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel) {         UIAlertAction in      }      // Add the actions     alertController.addAction(okAction)     alertController.addAction(cancelAction)      // Present the controller     self.presentViewController(alertController, animated: true, completion: nil) 

I can't figure out how to change the text color of the cancel and call actions. The title text is currently black and the cancel and call buttons are white. I'm making to make them all black for better visibility. Any ideas? Thanks!

like image 301
leerob Avatar asked Jan 12 '15 05:01

leerob


1 Answers

After some trial and error, I found this worked. Hopefully this will help future swift newcomers!

alertController.view.tintColor = UIColor.blackColor() 
like image 198
leerob Avatar answered Sep 22 '22 04:09

leerob