skyofdwarf / InteractiveDismiss

UIPresentationController subclass for interactive modal dismiss

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

InteractiveDismiss

CI Status Version License Platform

InteractiveDismiss-example

InteractiveDismiss is a subclass of UIPresentationController for interactive modal dismiss. It supports nested scroll views like UIScrollView, UITableView, and UICollectionView. To use InteractiveDismiss, just adopt UIViewControllerTransitioningDelegate protocol and return an instance of InteractiveDismiss in presentationController(forPresented:presenting:source:). And then set .custom to modalPresentationStyle before calling present(_:animated:completion).

extension YourModalViewController: UIViewControllerTransitioningDelegate {
    func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {
        InteractiveDismissPresentationController(presentedViewController: presented, presenting: presenting)
    }
}

extension YourModalViewController: InteractiveDismissPresentationDelegate {
    public var nestedScrollView: UIScrollView? { scrollView }
}

func presentModal() {
    let vc = YourModalViewController()
    
    vc.modalPresentationStyle = .custom
    vc.transitioningDelegate = vc
    
    self.present(vc, animated: true)
}

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

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

pod 'InteractiveDismiss'

Author

skyofdwarf, skyofdwarf@gmail.com

License

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

About

UIPresentationController subclass for interactive modal dismiss

License:MIT License


Languages

Language:Swift 89.8%Language:Ruby 10.2%