3

I would like to make the alert views in my app a solid white, instead of an semi-transparent white. Since UIAlertView extends UIView, I have tried the following:

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

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

Cbas
  • 6,003
  • 11
  • 56
  • 87

2 Answers2

0

It is advised against doing this, since simply solutions (like alpha = 1.0, etc) will not work. Therefore you are likely to be creating issues for the future if you try working your way around this. My advice is not to do it, but if you have to then subclass UIView and do it that way.

Charlie S
  • 4,366
  • 6
  • 59
  • 97
0

If you want alerts with solid white background without transparency then you can do this:

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

it works for both UIAlertController and UIAlertView.

Leszek Szary
  • 9,763
  • 4
  • 55
  • 62