UIAlertController change font color

后端 未结 8 779
时光取名叫无心
时光取名叫无心 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

    Before iOS 9.0 you could simply change the underlying view's tintColor like this:

    alertController.view.tintColor = UIColor.redColor()
    

    However, due to a bug introduced in iOS 9, you can either:

    1. Change the app tintColor in the AppDelegate.

      func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
          self.window.tintColor = UIColor.redColor()
          return true
      }
      
    2. Reapply the color in the completion block.

      self.presentViewController(alert, animated: true, completion: {() -> Void in
          alert.tintColor = UIColor.redColor()
      })
      

    See my other answer here: https://stackoverflow.com/a/37737212/1781087

提交回复
热议问题