Skip to content

Enables dragging interaction and animation of scrollView in a similar way to Facebook Messenger app.

License

Notifications You must be signed in to change notification settings

shingt/DraggableModalTransition

Repository files navigation

DraggableModalTransition

Build Status Version License Xcode 10.0+ iOS 10.0+ Swift 4.2+

Introduction

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

Example project is available at Example/DraggableModalTransition.xcodeproj.

Usage

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.

Requirements

  • iOS9+
  • Swift 4.2+
  • Xcode 10.0+

Installation

DraggableModalTransition is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "DraggableModalTransition"

Author

shingt

License

DraggableModalTransition is available under the MIT license. See the LICENSE file for more info.

About

Enables dragging interaction and animation of scrollView in a similar way to Facebook Messenger app.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published