Skip to content

Instantly share code, notes, and snippets.

@Aymenworks
Created November 15, 2020 14:41
override func viewDidLoad() {
// ...
for (index, face) in faces.enumerated() {
// ...
let panGesture = UIPanGestureRecognizer(target: self, action: #selector(self.handlePan(gesture:)))
bubbleView.addGestureRecognizer(panGesture)
}
}
@objc func handlePan(gesture: UIPanGestureRecognizer) {
switch gesture.state {
case .ended:
guard let bubbleView = gesture.view as? FaceView else {
return
}
let velocity = gesture.velocity(in: self.view)
let itemBehavior = UIDynamicItemBehavior(items: [bubbleView])
itemBehavior.addLinearVelocity(velocity, for: bubbleView)
animator.addBehavior(itemBehavior)
default:
break
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment