Giter Club home page Giter Club logo

rpmodalgesturetransition's Introduction

RPModalGestureTransition


You can dismiss modal by using gesture.

Usage

1.Define animation

You define animator class inherits UIViewControllerAnimatedTransitioning. I made this in TransitionAnimator.swift.

2.Set UIViewControllerTransitioningDelegate to modal

import UIKit

extension ModalViewController: UIViewControllerTransitioningDelegate {

    func presentationControllerForPresentedViewController(presented: UIViewController, presentingViewController presenting: UIViewController, sourceViewController source: UIViewController) -> UIPresentationController? {

        return BackgroundPresentationController(presentedViewController: presented, presentingViewController: presenting)
    }

    func animationControllerForPresentedController(presented: UIViewController, presentingController presenting: UIViewController, sourceController source: UIViewController) -> UIViewControllerAnimatedTransitioning? {

        return TransitionAnimator(isPresenting: true)
    }

    func animationControllerForDismissedController(dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {

        return TransitionAnimator(isPresenting: false)
    }

    func interactionControllerForPresentation(animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
        return nil
    }

    func interactionControllerForDismissal(animator: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
        guard let percentInteractiveTransition = percentInteractiveTransition else {
            return nil
        }
        
        return percentInteractiveTransition.isInteractiveDissmalTransition ? percentInteractiveTransition : nil
    }
}

3.Set InteractiveTransition to modal

Class InteractiveTransition inherits UIPercentDrivenInteractiveTransition.

class ModalViewController: UIViewController {
    
    var percentInteractiveTransition: InteractiveTransition?
    
    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
        
        modalPresentationStyle = .Custom
        transitioningDelegate = self
        
        percentInteractiveTransition = InteractiveTransition(attachedViewController: self)
    }

4.Define interactive animation

You have to define how animation change with gesture. You check InteractiveTransition.swift.

rpmodalgesturetransition's People

Contributors

naoyashiga avatar

Stargazers

Junkai Zheng avatar Money Chien avatar Erick Harris avatar Husnain Ali avatar Matheus avatar Jeoffrey Thirot avatar hey_its_sean avatar  avatar w353n avatar bin avatar Wei Qian avatar Keivan Shahida avatar atsumo avatar keisei_1092 avatar  avatar Kota avatar Chris Goldsby avatar  avatar Shamkhal Guliyev avatar pawel.io avatar Rocket avatar tooi avatar  avatar shima avatar Behrouz Pooladrak avatar Aymeric Gallissot avatar Viraj Patel avatar Hassan Mahmood avatar Larry Mickie avatar 陈建立 avatar HaviLee avatar  avatar secret avatar Yuki MIZUNO avatar Fabio Giolito avatar  avatar Donghua Li avatar Yoichi Tagaya avatar IKEDA Sho avatar Sergey Petruk avatar Abdulrahman Alfulayt avatar JB Lorenzo avatar  avatar Naoki IOROI avatar Victor Tatarasanu avatar  avatar Cameron Ehrlich avatar Abdulmomen Bsruki avatar Indrajit Chakrabarty avatar Cleber Santos avatar Lucas Farah avatar syxc avatar Javier Manzo avatar Jamie White avatar  avatar Muhammed Ballan avatar Sergio Utama avatar  avatar Sashank Gogula avatar  avatar Michael avatar Anthony avatar  avatar  avatar Henry Hardy avatar Trần Quang Duy avatar Bence Feher avatar Lan Qingyong avatar  avatar jerome avatar  avatar William Muro avatar Mykola Blyk avatar Ralitsa Ivanova avatar ikemai avatar Lasha Efremidze avatar  avatar Leonardo Borges Avelino avatar MohsinAli avatar Yatheesha B L avatar  avatar Dimo Hamdy avatar Michael Pchelnikov avatar Malte Schonvogel avatar Neetin Sharma avatar Dylan Beadle avatar John Manos avatar Carabineiro avatar Serhat Sezer avatar Ralph Li avatar Umit Kitapcigil avatar

Watchers

MohsinAli avatar  avatar Carabineiro avatar  avatar  avatar

rpmodalgesturetransition's Issues

Cocoapods

it'd be nice to have cocoapods support as well

View size

@naoyashiga How can I change the size of the view that pops up? To make it almost fill the whole screen?

Swift 3

it'd be cool to have a swift 3 version, if you have any interest to create a branch i would like to help with that.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.