[DEPRECEATED] Since iOS13 this is build-in feature
Since iOS10 UIViewPropertyAnimator gives us an amazing tool to make UIView animations interactive. this project is simple experiment, feel free to extend and customize - it is very simple!
- Copy
InteractiveDismissingclass to your project - Conform ypour modal viewciontroller to the
InteractiveDismissingprotocol
var animator: UIViewPropertyAnimator?
- Add
UIPanGestureRecognizerto your view
let panGesture = UIPanGestureRecognizer(target: self, action: #selector(ModalViewController.didTrackPanGesture))
view.addGestureRecognizer(panGesture)
- In your gesture handler simply call:
dismissInteractively(with: sender) {
self.dismiss(animated: false, completion: nil)
}
- Done.
