任何人都知道UIVisualEffect视图的错误会导致每个视图的模糊变得更轻/更清晰,添加的视图越多?
我有两个UIVisualEffectViews,其模糊效果很好。一旦我添加了以相同方式配置的第三个UIVisualEffectView,所有它们的模糊突然变得如上所述变亮了?有人遇到过这个吗?或者我做错了什么?
值得注意的是:模糊处于被聚光灯渲染的键盘视图控制器内部。
以下是我的设置代码:
//1
var blurEffect = UIBlurEffect(style: UIBlurEffectStyle.Dark)
var blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = CGRectMake(0, 0, self.frame.width/3-0.5, self.frame.height)
blurEffectView.opaque = true
self.addSubview(blurEffectView)
var vibrancyEffect = UIVibrancyEffect(forBlurEffect: blurEffect)
var vibrancyEffectView = UIVisualEffectView(effect: vibrancyEffect)
vibrancyEffectView.frame = self.bounds
blurEffectView.contentView.addSubview(vibrancyEffectView)
blurEffectView.contentView.addSubview(btn1)
//2
var blurEffect1 = UIBlurEffect(style: UIBlurEffectStyle.Dark)
var blurEffectView1 = UIVisualEffectView(effect: blurEffect1)
blurEffectView1.frame = CGRectMake(self.frame.width/3+0.5, 0, self.frame.width/3-0.5, self.frame.height)
self.addSubview(blurEffectView1)
var vibrancyEffect1 = UIVibrancyEffect(forBlurEffect: blurEffect1)
var vibrancyEffectView1 = UIVisualEffectView(effect: vibrancyEffect1)
vibrancyEffectView1.frame = self.bounds
blurEffectView1.contentView.addSubview(vibrancyEffectView1)
blurEffectView1.contentView.addSubview(btn2)
//3
var blurEffect2 = UIBlurEffect(style: UIBlurEffectStyle.Dark)
var blurEffectView2 = UIVisualEffectView(effect: blurEffect2)
blurEffectView2.frame = CGRectMake(2*(self.frame.width/3+0.25), 0, self.frame.width/3-0.5, self.frame.height)
self.addSubview(blurEffectView2)
var vibrancyEffect2 = UIVibrancyEffect(forBlurEffect: blurEffect2)
var vibrancyEffectView2 = UIVisualEffectView(effect: vibrancyEffect2)
vibrancyEffectView2.frame = self.bounds
blurEffectView2.contentView.addSubview(vibrancyEffectView2)
blurEffectView2.contentView.addSubview(btn3)