Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从iOS 8的UIAlertView中删除alpha_Ios_Ios8_Uialertview - Fatal编程技术网

从iOS 8的UIAlertView中删除alpha

从iOS 8的UIAlertView中删除alpha,ios,ios8,uialertview,Ios,Ios8,Uialertview,我希望我的应用程序中的警报视图为纯白,而不是半透明的白色。由于UIAlertView扩展了UIView,我尝试了以下方法: alert.backgroundColor = [UIColor whiteColor]; alert.alpha = 1; alert.opaque = YES; 但警报仍然是透明的。如何使其具有纯白背景?建议不要这样做,因为简单的解决方案(如alpha=1.0等)不起作用。因此,如果你努力解决这个问题,你很可能会为未来制造问题。我的建议是不要这样做,但如果必须将UIV

我希望我的应用程序中的警报视图为纯白,而不是半透明的白色。由于UIAlertView扩展了UIView,我尝试了以下方法:

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

但警报仍然是透明的。如何使其具有纯白背景?

建议不要这样做,因为简单的解决方案(如alpha=1.0等)不起作用。因此,如果你努力解决这个问题,你很可能会为未来制造问题。我的建议是不要这样做,但如果必须将UIView子类化并以这种方式进行操作。

如果希望警报具有纯白背景而不具有透明度,则可以执行以下操作:

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

它适用于UIAlertController和UIAlertView。

提出并回答了一个类似的问题