DraggableModalTransition enables dragging interaction and animation of scrollView in a similar way to Facebook Messenger app.
Inspired by zoonooz/ZFDragableModalTransition. Key difference is you can continue dragging scrollView after you have finished scrolling to top of it (See example below).
Example project is available at Example/DraggableModalTransition.xcodeproj
.
Set an instance of DraggableModalTransition
to transitioningDelegate
of viewController you want to present.
Note that you have to keep an instance of DraggableModalTransition
even after view is presented.
func presentModalView() {
let controller = ModalViewController()
let navigationController = UINavigationController(rootViewController: controller)
modalTransition = DraggableModalTransition(with: controller)
navigationController.transitioningDelegate = modalTransition
controller.modalViewControllerDelegate = modalTransition
present(navigationController, animated: true, completion: nil)
}
For now you also need to call modalViewDidScroll
in your scrollViewDidScroll
.
class ModalViewController {
weak var modalViewControllerDelegate: ModalViewControllerDelegate?
...
func scrollViewDidScroll(_ scrollView: UIScrollView) {
modalViewControllerDelegate?.modalViewDidScroll(scrollView)
}
}
See example project for more details.
- iOS9+
- Swift 4.2+
- Xcode 10.0+
DraggableModalTransition is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "DraggableModalTransition"
shingt
DraggableModalTransition is available under the MIT license. See the LICENSE file for more info.