How to change the background color of the UIAlertController?

You have to step some views deeper:

let subview = actionController.view.subviews.first! as UIView
let alertContentView = subview.subviews.first! as UIView
alertContentView.backgroundColor = UIColor.blackColor()

And maybe you want to keep original corner radius:

 alertContentView.layer.cornerRadius = 5;

Sorry for the “Swifting” but i’m not familiar with Objective-C. I hope that’s similar.

Of course it’s also important to change the title color of the actions. Unfortunately I don’t know, how to set the color of actions separately. But this is, how you change all button text colors:

actionController.view.tintColor = UIColor.whiteColor();

EDIT:

The corner radius of the UIAlertController has changed since this answer’s been posted! Replace this:

 alertContentView.layer.cornerRadius = 5;

to this:

 alertContentView.layer.cornerRadius = 15

Leave a Comment

tech