UIAlertController change font color

后端 未结 8 886
时光取名叫无心
时光取名叫无心 2021-02-05 06:43

Here\'s my code that creates the UIAlertController

    // Create the alert controller
    var alertController = UIAlertController(title: \"Are you sure you want          


        
8条回答
  •  醉酒成梦
    2021-02-05 07:27

    Below code is changing the UIAlertView title color.

      let alert = UIAlertController(title: messageTitle, message: messageText, preferredStyle: UIAlertControllerStyle.Alert)
    
      alert.setValue(NSAttributedString(string: messageTitle, attributes: [NSFontAttributeName : UIFont.systemFontOfSize(17),NSForegroundColorAttributeName : UIColor.redColor()]), forKey: "attributedTitle")
    
      alert.addAction(UIAlertAction(title: buttonText, style: UIAlertActionStyle.Default, handler: nil))
    
      parent.presentViewController(alert, animated: true, completion: nil)
    

    If you want to change button color then add following code after present View Controller.

      alert.view.tintColor = UIColor.redColor()
    

提交回复
热议问题