1

In the same way one would apply a pan gesture translation to the alpha value of a view, for example, is there a way to attach a pan gesture translation to a blur effect?

To animate a blur effect, one may do this:

effectView.effect = blur

UIView.animate(withDuration: duration, animations: {

    effectView.effect = nil

})

This animates the blur from 100% blur to 0% blur. I have a pan gesture bound to this animation and can't figure out if there is a way to bind the translation to the blur effect. Is this even possible?

More code

@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

    ...

}
lurning too koad
  • 2,698
  • 1
  • 17
  • 47

0 Answers0