Beginner Beginner - 6 months ago 31
iOS Question

How to change tint color of UIAlertController?

Can I change colors of the

UIAlertController
? A standard color is a blue color. And it's much close to the standard iOS apps. If it's customizable? How can I change colors of this? For example a button color.

Thanks!

Answer

You could just change the tintColor of the underlying view, however, due to a known bug (https://openradar.appspot.com/22209332), the tintColor is overridden by the application window's tintColor.

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()
    })