我有一个UIView
,我在viewDidLoad
设置了它的框架。然后我使用blurBackgroundForView
函数来模糊它:
override func viewDidLoad() {
super.viewDidLoad()
view.frame = CGRectMake(0, superView.frame.maxY-height, superView.frame.width, height)
// The view is supposed to peak in from the bottom
AnimationHelper.blurBackgroundForView(view)
}
static func blurBackgroundForView(view: UIView!){
view.backgroundColor = .clearColor()
let blurEffect = UIBlurEffect(style: .Light)
let blurEffectView = UIVisualEffectView(effect: blurEffect)
blurEffectView.frame = view.frame
view.insertSubview(blurEffectView, atIndex: 0)
}
}
问题是UIView
的背景是不模糊。
当我将blurBackgroundView(view)
的函数调用移到view.frame = ...
之上时
我看到一个模糊的视图,但模糊的视图要大得多。
答案 0 :(得分:1)
blurEffectView的框架应为CGRectMake(0,0,superview.frame.width,height)