Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change tint color of UIAlertController?

Tags:

ios

swift

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!

like image 531
Beginner Avatar asked Jun 09 '16 22:06

Beginner


1 Answers

You could just change the tintColor of the underlying view, however, due to a known bug introduced in iOS 9 (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.view.tintColor = UIColor.redColor()
    })
    
like image 89
guidev Avatar answered Sep 27 '22 17:09

guidev