You can dismiss modal by using gesture

Overview

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.

You might also like...
Presentation helps you to make tutorials, release notes and animated pages.
Presentation helps you to make tutorials, release notes and animated pages.

Presentation helps you to make tutorials, release notes and animated pages.

Letters animation allows you to click on different letters and accordingly it will animate letters in a cool way. It has a very attractive UI and is very easy to use.
Letters animation allows you to click on different letters and accordingly it will animate letters in a cool way. It has a very attractive UI and is very easy to use.

Letters Animation Cool Letters Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

Numbers animation allows you to click on different numbers and accordingly it will animate numbers in a cool way. It has a very attractive UI and is very easy to use.
Numbers animation allows you to click on different numbers and accordingly it will animate numbers in a cool way. It has a very attractive UI and is very easy to use.

Numbers Animation Cool Numbers Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

Reading animation allows you to click on the different page numbers and accordingly it will animate page changes in a cool way. It has a very attractive UI and is very easy to use.
Reading animation allows you to click on the different page numbers and accordingly it will animate page changes in a cool way. It has a very attractive UI and is very easy to use.

Reading Animation Cool Reading Animation in iOS written in Swift. Preview Table of content :- Description How to add in your project Requirement Licen

MotionBlur allows you to add motion blur effect to iOS animations.
MotionBlur allows you to add motion blur effect to iOS animations.

MotionBlur MotionBlur allows you to add motion blur effect to your animations (currently only position's change). See the accompanying blog post to le

UIImageView subclass that allows you to display a looped video and dynamically switch it.
UIImageView subclass that allows you to display a looped video and dynamically switch it.

AKVideoImageView Motivation AKVideoImageView was created because I wasn't satisfied with the standard AVPlayer when I was implementing a video backgro

Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions
Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions

Various view's effects for iOS, written in Swift. Allows you to animate views nicely with easy to use extensions. Every animation is randomized. Currently supported animations:

ButtonClickStyle - This is a Customizable/Designable Button View, with 15 animated click styles, that allows you to design your own buttons from subviews, in storyboard and xib right away.
ButtonClickStyle - This is a Customizable/Designable Button View, with 15 animated click styles, that allows you to design your own buttons from subviews, in storyboard and xib right away.

ButtonClickStyle - This is a Customizable/Designable Button View, with 15 animated click styles, that allows you to design your own buttons from subviews, in storyboard and xib right away.

Framework to help you better manage UITableViews
Framework to help you better manage UITableViews

UITableView made simple 🙌 Main Features 🙉 Skip the UITableViewDataSource & UITableViewDelegate boilerplate and get right to building your UITableVie

Owner
Naoya Sugimoto
Naoya Sugimoto
Designed for gesture-driven animations. Fast, simple, & extensible!

Yet Another Animation Library Designed for gesture-driven animations. Fast, simple, & extensible! It is written in pure swift 3.1 with protocol orient

Luke Zhao 509 Dec 21, 2022
Awesome IOS Styling with SwiftUI, Animation, Effects, Gesture ⭐️

Awesome SwiftUI Styling with SwiftUI ⭐️ This repository is dedicated to IOS styling using SwiftUI. (often using Other Libraries.) I started collecting

SeungYeub Baek 1 Apr 5, 2022
Poi - You can use tinder UI like tableview method

Poi You can use tinder UI like tableview method Installation Manual Installation Use this command git clone [email protected]:HideakiTouhara/Poi.git Imp

null 65 Nov 7, 2022
Design-system-demo - This example code is bare-bones to show you what this framework can do

Basic Style Dictionary This example code is bare-bones to show you what this fra

Tylen St Hilaire 0 Feb 3, 2022
jasu 29 Dec 20, 2022
Protoyping-Project WallAngle - With this App, you can measure the angle without searching for tools and calculations

Protoyping-Project_WallAngle This is the App that I made for the Prototyping Pro

null 1 Apr 4, 2022
Each step you take reveals a new horizon. You have taken the first step today.

The story Seeing the animations behind Paper, or the transitions behind Mail, being in a world of flat design and transitions, user interaction, app b

Ramon Gilabert 152 Nov 3, 2022
WifiView Pod can animate wifi signal strength

WifiView WifiView is animateable UIView that can significantly enhance your users’ experiences and set your app apart from the rest of the pack. It is

Jawad Ali 12 Sep 27, 2022
A lightweight loading animation that can be applied to any SwiftUI view with 1 line of code.

SimpleAFLoader A lightweight loading animation that can be applied to any SwiftUI view with 1 line of code. All animations are built using the SwiftUI

Fahim Rahman 2 Aug 25, 2022