Painless custom transitioning. Easy extend, easy setup, just focus on animations.

Overview

TransitionManager

Painless custom transitioning. Easy extend, easy setup, just focus on animations.

Installation

CocoaPods

You can use CocoaPods to install TransitionManager by adding it to your Podfile:

platform :ios, '8.0'
use_frameworks!
pod 'TransitionManager'

To get the full benefits import TransitionManager wherever you import UIKit

import UIKit
import TransitionManager

Manually

  1. Download and drop /TransitionManagerfolder in your project.
  2. Congratulations!

Usage

Copy & paste TransitionManager.swift into your project.

  • Declare a TransitionManager object.
  • Init it with a TransitionManagerAnimation
  • Assign it as your navigation controller's delegate if you use navigation controller.
  • Else assign it as your view controller's transitioningDelegate.
	
	var transition: TransitionManager!
	    
	override func viewDidLoad() {
	   super.viewDidLoad()
	   
	   transition = TransitionManager (transitionAnimation: FadeTransitionAnimation())
	   navigationController?.delegate = transition
	}
	

Creating Transition Animations

Create a subclass of TransitionManagerAnimation

	class FadeTransitionAnimation: TransitionManagerAnimation {

	}

TransitionManagerAnimation class implements TransitionManagerDelegate protocol.

TransitionManagerDelegate
protocol TransitionManagerDelegate {

    /// Transition nimation method implementation
    func transition(
        container: UIView,
        fromViewController: UIViewController,
        toViewController: UIViewController,
        isDismissing: Bool,
        duration: NSTimeInterval,
        completion: () -> Void)

    /// Interactive transitions,
    /// update percent in gesture handler
    var interactionTransitionController: UIPercentDrivenInteractiveTransition? { get set }
}

For transition animation, we should override transition func and write our custom animation in it.

class FadeTransitionAnimation: TransitionManagerAnimation {
    override func transition(
        container: UIView,
        fromViewController: UIViewController,
        toViewController: UIViewController,
        isDismissing: Bool,
        duration: NSTimeInterval,
        completion: () -> Void) {
        if isDismissing {
            closeAnimation(container,
                fromViewController: fromViewController,
                toViewController: toViewController,
                duration: duration,
                completion: completion)
        } else {
            openAnimation(container,
                fromViewController: fromViewController,
                toViewController: toViewController,
                duration: duration,
                completion: completion)
        }
    }    
}

One important part is completion() must be called because the TransitionManager finishes transition after it gets called.

Interaction Transition

Interaction transition has 3 parts:

  • Init interactionTransitionController and either pop or push navigation controller when gesture (interaction) starts.
  • Calculate your percents on gesture change and updateInteractiveTransition: with that percent
  • When gesture ended, decide if your transition complete or not and give information to your interactionTransitionController with finishInteractiveTransition () and cancelInteractiveTransition ()

Easier TransitionManager setup

You can create a TransitionManagerAnimation container enum and give it all your animations

	enum TransitionManagerAnimations {
	    case Fade
	    case Pull
	}

Write a func that returns correct transition animation in enum

enum TransitionManagerAnimations {
    case Fade
    case Pull
    
    func transitionAnimation () -> TransitionManagerAnimation {
        switch self {
        case .Fade:
            return FadeTransitionAnimation()
        case .Pull:
            return PullTransitionAnimation()
        }
    }
}

Extend TransitionManager and write a new init method like

extension TransitionManager {
    convenience init(transition: TransitionManagerAnimations) {
        self.init(transitionAnimation: transition.transitionAnimation())
    }
}

Now you can create TransitionManager in your view controller like

transition = TransitionManager(transition: .Pull)
navigationController?.delegate = transition
You might also like...
A Swift library to take the power of UIView.animateWithDuration(_:, animations:...) to a whole new level - layers, springs, chain-able animations and mixing view and layer animations together!
A Swift library to take the power of UIView.animateWithDuration(_:, animations:...) to a whole new level - layers, springs, chain-able animations and mixing view and layer animations together!

ver 2.0 NB! Breaking changes in 2.0 - due to a lot of requests EasyAnimation does NOT automatically install itself when imported. You need to enable i

SwiftUI Animation Library. Useful SwiftUI animations including Loading/progress, Looping, On-off, Enter, Exit, Fade, Spin and Background animations that you can directly implement in your next iOS application or project. The library also contains huge examples of spring animations such as Inertial Bounce, Shake, Twirl, Jelly, Jiggle, Rubber Band, Kitchen Sink and Wobble effects. Browse, find and download the animation that fits your needs. Our Guillotine Menu Transitioning Animation implemented in Swift reminds a bit of a notorious killing machine.
Our Guillotine Menu Transitioning Animation implemented in Swift reminds a bit of a notorious killing machine.

GuillotineMenu.swift Inspired by this project on Dribbble Also, read how it was done in our blog Requirements iOS 8.0+ Xcode 10 Swift 5.0 (v 4.1+) Swi

UIViewController subclass inspired by
UIViewController subclass inspired by "Inbox by google" animated transitioning.

SAInboxViewController SAInboxViewController realizes Inbox like view transitioning. You can launch sample project on web browser from here. Features I

Enhanced transitioning between UICollectionView layouts in iOS.

TLLayoutTransitioning Enhanced transitioning between UICollectionView layouts in iOS. ##Overview TLLayoutTransitioning provides a TLLayoutTransition t

(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey 🍯 to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.

wobbly See Wobbly in action (examples) Add a drop of honey 🍯 to your project wobbly has a bunch of cool, fun, and easy to use iOS animations for you

Argo is a library that lets you extract models from JSON or similar structures in a way that's concise, type-safe, and easy to extend
Argo is a library that lets you extract models from JSON or similar structures in a way that's concise, type-safe, and easy to extend

Argo is a library that lets you extract models from JSON or similar structures in a way that's concise, type-safe, and easy to extend. Using Argo

A video composition framework build on top of AVFoundation. It's simple to use and easy to extend.
A video composition framework build on top of AVFoundation. It's simple to use and easy to extend.

A high-level video composition framework build on top of AVFoundation. It's simple to use and easy to extend. Use it and make life easier if you are implementing video composition feature.

A fast, convenient and nonintrusive conversion framework between JSON and model. Your model class doesn't need to extend any base class. You don't need to modify any model file.

MJExtension A fast, convenient and nonintrusive conversion framework between JSON and model. 转换速度快、使用简单方便的字典转模型框架 📜 ✍🏻Release Notes: more details Co

Metron is a comprehensive collection of geometric functions and types that extend the 2D geometric primitives

Metron Geometry, simplified. Metron is a comprehensive collection of geometric functions and types that extend the 2D geometric primitives provided by

A Cocoa library to extend the Objective-C programming language.

The Extended Objective-C library extends the dynamism of the Objective-C programming language to support additional patterns present in other programm

A Library to extend SwiftUI Controls
A Library to extend SwiftUI Controls

Introduction SwiftUICompatKit is an open source project that enables accessing controls that has not been developed or have limited functionality in S

A Set of Tools To Extend UIKit (Classic iOS Framework)
A Set of Tools To Extend UIKit (Classic iOS Framework)

RVS_UIKit_Toolbox A set of basic UIKit tools, for Swift iOS app development. Overview This package offers a few extensions of standard UIKit classes,

An easy to use and setup floating view for your app. 🎡
An easy to use and setup floating view for your app. 🎡

HHFloatingView An easy to use and setup floating view for your app. 🎡 Installation Manually - Add HHFloatingView/Source folder to your Project. And y

Use any custom view as custom callout view for MKMapView with cool animations. Use any image as annotation view.
Use any custom view as custom callout view for MKMapView with cool animations. Use any image as annotation view.

MapViewPlus About MapViewPlus gives you the missing methods of MapKit which are: imageForAnnotation and calloutViewForAnnotationView delegate methods.

Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more.
Codeless drop-in universal library allows to prevent issues of keyboard sliding up and cover UITextField/UITextView. Neither need to write any code nor any setup required and much more.

IQKeyboardManager While developing iOS apps, we often run into issues where the iPhone keyboard slides up and covers the UITextField/UITextView. IQKey

A lightweight, one line setup, iOS / OSX network debugging library! 🦊
A lightweight, one line setup, iOS / OSX network debugging library! 🦊

Netfox provides a quick look on all executed network requests performed by your iOS or OSX app. It grabs all requests - of course yours, requests from

MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup UIPresentationController size and feel form sheet.
MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding support for iPhone and additional opportunities to setup UIPresentationController size and feel form sheet.

MZFormSheetPresentationController MZFormSheetPresentationController provides an alternative to the native iOS UIModalPresentationFormSheet, adding sup

Comments
  • Correct the spelling of CocoaPods in README

    Correct the spelling of CocoaPods in README

    This pull requests corrects the spelling of CocoaPods 🤓 https://github.com/CocoaPods/shared_resources/tree/master/media

    Created with cocoapods-readme.

    opened by ReadmeCritic 0
  • Issue when presenting a UINavigationController.

    Issue when presenting a UINavigationController.

    Hi, i tried this code let navi = UINavigationController(rootViewController: ModalViewController()) navi.transitioningDelegate = self.transitionManager self.present(navi, animated: true, completion: nil)

    with my own custom animation: `class ScaleTransitionAnimation: TransitionManagerAnimation { private weak var panningViewController: UIViewController?

    override func transition(
        container: UIView,
        fromViewController: UIViewController,
        toViewController: UIViewController,
        isDismissing: Bool,
        duration: TimeInterval,
        completion: @escaping () -> Void) {
        if isDismissing {
            closeAnimation(
                container: container,
                fromViewController: fromViewController,
                toViewController: toViewController,
                duration: duration,
                completion: completion)
        } else {
            openAnimation(
                container: container,
                fromViewController: fromViewController,
                toViewController: toViewController,
                duration: duration,
                completion: completion)
        }
    }
    
    func openAnimation (
        container: UIView,
        fromViewController: UIViewController,
        toViewController: UIViewController,
        duration: TimeInterval,
        completion: @escaping () -> Void) {
        
        container.addSubview(toViewController.view)
        toViewController.view.top = fromViewController.view.bottom
        toViewController.view.addGestureRecognizer(UIPanGestureRecognizer(target: self, action: #selector(handlePan(pan:))))
        panningViewController = toViewController
        
        UIView.animate(
            withDuration: duration,
            animations: {
                toViewController.view.top = 0
        },
            completion: { finished in
                completion()
        })
    }
    
    func closeAnimation (
        container: UIView,
        fromViewController: UIViewController,
        toViewController: UIViewController,
        duration: TimeInterval,
        completion: @escaping () -> Void) {
        
        container.addSubview(toViewController.view)
        container.bringSubviewToFront(fromViewController.view)
        
        UIView.animate(
            withDuration: duration,
            animations: {
                fromViewController.view.frame = CGRect(x: 60, y: 400, width: 120, height: 120)
        },
            completion: { finished in
                completion()
        })
    }
    
    @objc func handlePan(pan: UIPanGestureRecognizer) {
        let percent = pan.translation(in: pan.view!).y / pan.view!.bounds.size.height
        switch pan.state {
        case .began:
            interactionTransitionController = UIPercentDrivenInteractiveTransition()
            panningViewController?.dismiss(animated: true, completion: {
                self.interactionTransitionController?.finish()
            })
        case .changed:
            interactionTransitionController!.update(percent)
        case .ended:
            if percent > 0.5 {
                interactionTransitionController!.finish()
                panningViewController = nil
            } else {
                interactionTransitionController!.cancel()
            }
            interactionTransitionController = nil
        default:
            return
        }
    }
    

    }` but the transition is not correct, presenting a UIViewController is oke. Can you check that?

    opened by junestchick 0
Releases(0.3)
Owner
Cem Olcay
iOS Developer
Cem Olcay
Custom-Transition - A repo about custom transition between two view controllers

Custom-Transition in SWIFT This is a repo about custom transition between two vi

Prakash Chandra Awal 0 Jan 6, 2022
SamuraiTransition is an open source Swift based library providing a collection of ViewController transitions featuring a number of neat “cutting” animations.

SamuraiTransiton is a ViewController transition framework in Swift. It is an animation as if Samurai cut out the screen with a sword. transition types

hachinobu 273 Dec 29, 2022
Easy interactive interruptible custom ViewController transitions

Introduction Transition is a library that helps you build iOS view controller transitions. Implementing a nice interactive custom view controller tran

Touchwonders 2.6k Dec 20, 2022
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 simple way to create custom interactive UIViewController transitions

EasyTransitions is a library that helps developers create custom interactive transitions using simple functions defined in a protocol and avoid handli

Marcos Griselli 1.6k Jan 1, 2023
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

Airin 642 Nov 17, 2022
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

Ivan Vorobei 965 Dec 17, 2022
NP-Open-House-Setup - Automated setup utility and instructions for Friction booth at NP Open House 2022

Friction Setup Setup Instructions Friction setup Start up the iMac Give it a cou

Jia Chen 0 Jan 4, 2022
Painless high-performance audio on iOS and Mac OS X

An analgesic for high-performance audio on iOS and OSX. Really fast audio in iOS and Mac OS X using Audio Units is hard, and will leave you scarred an

Alex Wiltschko 2.2k Nov 23, 2022
A collection of animations for iOS. Simple, just add water animations.

DCAnimationKit A collection of animations for iOS Simply, just add water! DCAnimationKit is a category on UIView to make animations easy to perform. E

Dalton 797 Sep 23, 2022