Remove alpha from UIAlertView in iOS 8

I would like to make the alert view in my application solid white, not translucent white. Since UIAlertView extends UIView, I've tried the following:

alert.backgroundColor = [UIColor whiteColor];
alert.alpha = 1;
alert.opaque = YES;

      

but the warning continues to be transparent. How can I make it a solid white background?

+3


source to share


2 answers


It is not recommended to do this as a simple solution (like alpha = 1.0, etc.) will not work. Therefore, you are likely to create problems for the future if you try to work around it. My advice is not to do this, but if you need to subclass the UIView and do it that way.



0


source


If you want to get alerts with a solid white background without transparency, you can do this:

UIVisualEffectView.appearance(whenContainedInInstancesOf: [UIAlertController.classForCoder() as! UIAppearanceContainer.Type]).backgroundColor = UIColor.white

      



it works for both UIAlertController and UIAlertView.

0


source







All Articles