A UIKit custom modal transition that simulates an elastic drag

Overview

ElasticTransition ObjC Version

This is the Objective-C Version of Elastic Transition written in Swift by lkzhao https://github.com/lkzhao/ElasticTransition

A UIKit custom modal transition that simulates an elastic drag. Written in Objective-C. Feel free to contribute!

demo

Installation

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

pod "ElasticTransitionObjC"

Usage

First of all, in your view controller, create an instance of ElasticTransition

- (void)viewDidLoad {

//...

    ElasticTransition *transition = [[ElasticTransition alloc] init];

    // customization
    transition.sticky           = YES;
    transition.showShadow       = YES;
    transition.panThreshold     = 0.4;
    transition.transformType    = TRANSLATEMID;

//...

}

Use as navigation controller's delegate

Simply assign the transition to your navigation controller's delegate

    navigationController.delegate =transition

Present as modal

In prepareForSegue, assign the transition to be the transitioningDelegate of the destinationViewController. Also, dont forget to set the modalPresentationStyle to UIModalPresentationCustom

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{

    segue.destinationViewController.transitioningDelegate = transition;
    segue.destinationViewController.modalPresentationStyle = UIModalPresentationCustom;

}

In your modal view controller .h implement the ElasticMenuTransitionDelegate

@interface MenuViewController: UIViewController 

@end

Then in your .m file synthesize the property and provide the contentLength value

@implementation MenuViewController

@synthesize contentLength;

-(id)initWithCoder:(NSCoder *)aDecoder{

    self = [super initWithCoder:aDecoder];

    if (self) {

        self.contentLength = 320.0;

        //...
    }

    return self;
}

@end
Interactive transition for modal transition

First, construct a pan gesture recognizer

UIPanGestureRecognizer *panGR = [[UIPanGestureRecognizer alloc] init];
[panGR addTarget:self action:@selector(handlePan:)];
[self.view addGestureRecognizer:panGR];

Then implement your gesture handler and fo the following:

-(void)handlePan:(UIPanGestureRecognizer*)pan{

    if (pan.state == UIGestureRecognizerStateBegan){
        // Here, you can do one of two things
        // 1. show a viewcontroller directly
        UIViewController *nextViewController = // construct your VC ...
        [transition startInteractiveTransitionFromViewController:self ToViewController:nextViewController GestureRecognizer:pan];
        // 2. perform a segue
        [transition startInteractiveTransitionFromViewController:self SegueIdentifier:@"menu" GestureRecognizer:pan];
    }else{
        [transition updateInteractiveTransitionWithGestureRecognizer:pan];
    }
}
Interactive transition for dismissing the modal
  1. Implement ElasticMenuTransitionDelegate in your modal view controller and set
    self.dismissByBackgroundTouch   = YES;
    self.dismissByBackgroundDrag    = YES;
    self.dismissByForegroundDrag    = YES;
  1. Or use your own panGestureRecognizer and call dissmissInteractiveTransition in your handler
-(void)handlePan:(UIPanGestureRecognizer*)pan{
    if (pan.state == UIGestureRecognizerStateBegan){
        [transition dismissInteractiveTransitionViewController:vc GestureRecognizer:pan Completion:nil];
    }else{
        [transition updateInteractiveTransitionWithGestureRecognizer:pan];
    }
}

Authors

lkzhao, taglia3, [email protected]

License

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

You might also like...
Simulates cellular automata patterns according to rules of Wolfram Alpha.
Simulates cellular automata patterns according to rules of Wolfram Alpha.

Cellular Automata App Simulates cellular automata patterns according to rules of Wolfram Alpha. What can I do with this? This app is designed with the

ChainPageCollectionView  A custom View with two level chained collection views and fancy transition animation
ChainPageCollectionView A custom View with two level chained collection views and fancy transition animation

ChainPageCollectionView A custom View with two level chained collection views and fancy transition animation. Demo Requirements iOS 9.0+ Xcode 8 Insta

MMPlayerView - Custom AVPlayerLayer on view and transition player with good effect like youtube and facebook
MMPlayerView - Custom AVPlayerLayer on view and transition player with good effect like youtube and facebook

MMPlayerView Demo-Swift List / Shrink / Transition / Landscape MMPlayerLayer ex. use when change player view frequently like tableView / collectionVie

Custom interactive transition like Apple Music iOS App (iOS 9). written in Swift.
Custom interactive transition like Apple Music iOS App (iOS 9). written in Swift.

MusicPlayerTransition Custom interactive transition like Apple Music iOS App. written in Swift. Demo See demo on Appetize.io Using Transition Animator

SPLarkController - Custom transition between controllers. Settings controller for your iOS app.
SPLarkController - Custom transition between controllers. Settings controller for your iOS app.

SPLarkController About Transition between controllers to top. You can change animatable height after presentation controller. For presentation and dis

ZoomTransitioning provides a custom transition with image zooming animation and swiping the screen edge.

ZoomTransitioning Overview ZoomTransitioning provides a custom transition with image zooming animation. When you use this library with UINavigationCon

Custom transition between controllers. Settings controller for your iOS app.
Custom transition between controllers. Settings controller for your iOS app.

SPLarkController About Transition between controllers to top. You can change animatable height after presentation controller. For presentation and dis

Custom transition between viewcontrollers holding tableviews
Custom transition between viewcontrollers holding tableviews

Custom transition between viewcontrollers holding tableviews. Each cell is animated to simulate a 'wave effect'. Read more about transitions here and

Custom transition between two collection view layouts
Custom transition between two collection view layouts

Display Switcher We designed a UI that allows users to switch between list and grid views on the fly and choose the most convenient display type. List

A draggable modal for iOS Applications.
A draggable modal for iOS Applications.

Mantle Modal Draggable Modal, PopUp or Menu written in Swift. Description A simple modal resource that uses a UIScrollView to allow the user to close

You can dismiss modal viewcontroller like Facebook Messenger by pulling scrollview or navigationbar in Swift.
You can dismiss modal viewcontroller like Facebook Messenger by pulling scrollview or navigationbar in Swift.

PullToDismiss PullToDismiss provides dismiss modal viewcontroller function like Facebook Messenger by pulling scrollview or navigationbar with smooth

iOS simple project to create half-screen modal view controller with pan
iOS simple project to create half-screen modal view controller with pan

Simple Half-screen view controller, draggable and less code (learning purpose)

Simple way to set up half modal view
Simple way to set up half modal view

HalfModalView Requirements iOS 9.0+ Xcode 10.0+ Swift 4.0+ Example Installation CocoaPods is a dependency manager for Cocoa projects. You can install

Half modal view for SwiftUI
Half modal view for SwiftUI

ResizableSheet ResizableSheeet is a half modal view library for SwiftUI. You can easily implement a half modal view. Target Swift5.5 iOS14+ Installati

A modal passcode input and validation view controller for iOS
A modal passcode input and validation view controller for iOS

TOPasscodeViewController A modal passcode input and validation view controller for iOS. TOPasscodeViewController is an open-source UIViewController su

A beautiful activity indicator and modal alert written in Swift (originally developed for my app DoodleDoodle) Using blur effects, translucency, flat and bold design - all iOS 8 latest and greatest
A beautiful activity indicator and modal alert written in Swift (originally developed for my app DoodleDoodle) Using blur effects, translucency, flat and bold design - all iOS 8 latest and greatest

SwiftSpinner SwiftSpinner is an extra beautiful activity indicator with plain and bold style. It uses dynamic blur and translucency to overlay the cur

Swift UI Kit to present clean modal/alert
Swift UI Kit to present clean modal/alert

CleanyModal is a good way to use UI-Customised alerts with ease Features Present some kind of clean alerts (With same API as UIAlertViewController) Ad

You can dismiss modal viewcontroller like Facebook Messenger by pulling scrollview or navigationbar in Swift.
You can dismiss modal viewcontroller like Facebook Messenger by pulling scrollview or navigationbar in Swift.

PullToDismiss PullToDismiss provides dismiss modal viewcontroller function like Facebook Messenger by pulling scrollview or navigationbar with smooth

BottomSheetDemo - Bottom sheet modal view controller with swift
BottomSheetDemo - Bottom sheet modal view controller with swift

当我们想弹出一个预览视图,bottom sheet modal view controller 非常实用。在 iOS 中,长按拖拽手势可以让 controlle

Comments
  • Rotating pan = going to crazy mode

    Rotating pan = going to crazy mode

    hey when I try to to play with view and rotate my finger on screen a little fast, its going to crazy mode and takes too long too stop moving. Is there any way prevent this?

    opened by MojtabaHs 1
Releases(0.1)
Owner
Matteo Tagliafico
I'm an Electronic Engineer with the passion for iOS development
Matteo Tagliafico
A custom modal transition that presents and dismiss a controller with an expanding bubble effect.

A custom modal transition that presents and dismiss a controller inside an expanding and shrinking bubble. Screenshot Usage Install through CocoaPods:

Andrea Mazzini 3.3k Dec 28, 2022
A custom modal transition that presents a controller with an expanding effect while sliding out the presenter remnants.

DAExpandAnimation A custom modal transition that presents a controller with an expanding effect while sliding out the presenter remnants. Screenshot I

Denis Avdeev 578 Nov 29, 2022
Elastic pull to refresh for iOS developed in Swift

DGElasticPullToRefresh Elastic pull to refresh compontent developed in Swift Inspired by this Dribbble post: Pull Down to Refresh by Hoang Nguyen Tuto

Danil Gontovnik 3.7k Jan 3, 2023
Elastic pull to refresh compontent developed in Swift

DGElasticPullToRefresh Elastic pull to refresh compontent developed in Swift Inspired by this Dribbble post: Pull Down to Refresh by Hoang Nguyen Tuto

null 0 Dec 4, 2021
A simple to use iOS/tvOS/watchOS SDK to help get you off the ground quickly and efficiently with your Elastic Path Commerce Cloud written in Swift.

Elastic Path Commerce Cloud iOS Swift SDK A simple to use iOS/tvOS/watchOS SDK to help get you off the ground quickly and efficiently with your Elasti

Moltin 36 Aug 1, 2022
Easy-to-use segues in SwiftUI, allowing for presenting views using common UIKIt Segue types - push, modal and popover

Easy-to-use segues in SwiftUI, allowing for presenting views using common UIKIt Segue types - push, modal and popover

Gordan Glavaš 5 Apr 16, 2022
Appstore card animation transition. UICollectionView and UITableView card expand animated transition

Appstore card animation transition. UICollectionView and UITableView card expand animated transition. This library tries to add the appstore transition to your own app. The goal is to be as simple as possible to integrate in an app while keeping the flexibility and customization alive.

appssemble 544 Dec 28, 2022
Teatanic is an iOS application that simulates a tea shop.

teatanic Teatanic is an iOS application that simulates a tea shop. A user is able to search among different tea types and "buy" it. purpose This appli

null 2 Oct 6, 2021
ClearScore - This application simulates a credit check on a user by making a call to an API and displaying the data

ClearScore Description This application simulates a credit check on a user by ma

Sashen Pillay 0 Jan 11, 2022
OrderManagementSystem - A real-time system that simulates the fulfillment of delivery orders for a kitchen

This project showcases the implementation of an order management system used for

Amer Hukić 27 Jul 24, 2022