UIBlurEffect 不影响它背后的 UIView
UIBlurEffect doesn't affect on UIView behind it
我是这样定义的 UIVisualEffectView
:
UIApplication.sharedApplication().delegate?.window??.addSubview(self)
let blurEffect = UIBlurEffect(style: .Light)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = CGRectMake(20, 30, 300, 50)
blurEffectView.backgroundColor = UIColor.yellowColor()
addSubview(blurEffectView)
但这是一个结果:
但是正如你所看到的,navigationBar 的标题一点都不模糊。怎么了?
superview
of blurEffectView
必须有:
alpha = 1
backgroundColor = UIColor.clearColor()
我是这样定义的 UIVisualEffectView
:
UIApplication.sharedApplication().delegate?.window??.addSubview(self)
let blurEffect = UIBlurEffect(style: .Light)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = CGRectMake(20, 30, 300, 50)
blurEffectView.backgroundColor = UIColor.yellowColor()
addSubview(blurEffectView)
但这是一个结果:
但是正如你所看到的,navigationBar 的标题一点都不模糊。怎么了?
superview
of blurEffectView
必须有:
alpha = 1
backgroundColor = UIColor.clearColor()