Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change UIAlertController Background Tint

Yes, I know. You can't change the appearance of a UIAlertController. I don't want to change the background of the UIAlertController itself, I want to change the tint of the view's background. You know how it's like a transparent black color? I want to change that color to clear. How would I do this?

like image 804
Jacob Cavin Avatar asked Jul 07 '17 00:07

Jacob Cavin


1 Answers

For swift 3 UIAlertController change background color.

let alert = UIAlertController(title: "validate",message: "Check the process", preferredStyle: .alert)
let dismissAction = UIAlertAction(title: "Dismiss", style: .destructive, handler: nil)
alert.addAction(dismissAction)
self.present(alert, animated: true, completion:  nil)
// change the background color
let subview = (alert.view.subviews.first?.subviews.first?.subviews.first!)! as UIView
subview.layer.cornerRadius = 1
subview.backgroundColor = UIColor(red: (195/255.0), green: (68/255.0), blue: (122/255.0), alpha: 1.0)
like image 79
Digvijaysinh Gida Avatar answered Nov 20 '22 02:11

Digvijaysinh Gida