有没有办法将手势转换附加到模糊效果?

时间:2017-09-24 20:19:51

标签: ios uiblureffect

以同样的方式将平移手势转换应用于视图的alpha值,例如,有没有办法将平移手势转换附加到模糊效果?

要为模糊效果设置动画,可以这样做:

effectView.effect = blur

UIView.animate(withDuration: duration, animations: {

    effectView.effect = nil

})

这可以将模糊从100%模糊到0%模糊。我有一个绑定到这个动画的平移手势,无法弄清楚是否有办法将平移绑定到模糊效果。这甚至可能吗?

更多代码

@objc func gestureHandler(_ gesture: UIPanGestureRecognizer) {

    let translation: CGPoint = gesture.translation(in: gesture.view)

    switch gesture.state {

    case .began:

        gesture.setTranslation(CGPoint.zero, in: gesture.view)
        effectViewTo.effect = blur

    case .changed:

        gesture.setTranslation(CGPoint.zero, in: gesture.view)
        someView.center = CGPoint(x: someView.center.x + translation.x, y: someView.center.y)
        // adjust blur here

    ...

}

0 个答案:

没有答案