1

我有一个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 = ... 我得到了一个模糊的视图,但模糊的视图非常大。

4

1 回答 1

1

blurEffectView 的框架应该是 CGRectMake(0, 0, superview.frame.width, height)

于 2016-02-13T04:04:11.383 回答