从iOS 8中的UIAlertView中删除alpha

时间:2014-10-22 06:08:09

标签: ios ios8 uialertview

我想在我的应用中将警报视图设为纯白色,而不是半透明白色。由于UIAlertView扩展了UIView,我尝试了以下内容:

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

但警报继续透明。如何让它具有纯白色背景?

2 个答案:

答案 0 :(得分:0)

建议不要这样做,因为简单的解决方案(如alpha = 1.0等)将无效。因此,如果您尝试解决此问题,您可能会为未来制造问题。我的建议是不要这样做,但是如果你必须将子类化为UIView并按此方式进行。

答案 1 :(得分:0)

如果您想要具有纯白色背景且没有透明度的警报,则可以执行以下操作:

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

它适用于UIAlertController和UIAlertView。