API to make great custom transitions in one method

Overview

AZTransitions

CocoaPods Compatible Carthage Compatible SPM Compatible Platform Twitter GitHub license

Make your modal transition with custom animation. AZTransitions helps you think about creativity, giving specific API methods.

Visual Example

Inside this repository you can try iOS Example target with example FashionTransition.swift class:

Animation example

Installation

  • Add the following to your Podfile and run pod install
pod 'AZTransitions'
  • or add the following to your Cartfile and run carthage update
github "azimin/AZTransitions"
dependencies: [
    .package(url: "https://github.com/azimin/AZTransitions.git", .upToNextMajor(from: "0.26.0"))
]
  • or clone as a git submodule,

  • or just copy AZTransitions/Source/CustomModalTransition.swift into your project.

Code Example

To create any custom transition just subclass CustomModalTransition:

class FashionTransition: CustomModalTransition { 
  override init() {
    super.init(duration: 0.5)
  }
}

--

Then set as az_modalTransition to nessesary view just before presenting it

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
  segue.destination.customModalTransition = FashionTransition()
}

or

func show() {
  let viewController = UIViewController()
  viewController.customModalTransition = FashionTransition()
  self.present(viewController, animated: true, completion: nil)
}

--

To have custom present animation, just implement performTransition(interactive: Bool) inside your FashionTransition class:

func performTransition(interactive: Bool) {
  self.presentedViewController.view.alpha = 0.0
    
  UIView.animate(withDuration: duration, animations: {
    self.presentedViewController.view.alpha = 1.0
    self.presentingViewController.view.alpha = 0.0
  }, completion: { (completed) in
    self.presentingViewController.view.alpha = 1.0
    self.finishAnimation(completion: nil)
  })
}

As you may have guessed, you have different properties. The main ones:

  • duration — transition duration
  • presentingViewController — the presenting view controller (bottom one)
  • presentedViewController — view controller that is going to be presented (top one)

You can animate them as you want.

🔥 IMPORTANT 🔥 don't forget to call finishAnimation(completion: nil) in the end.

In this case animation will be:

Animation code example

UIModalPresentationStyle

Of course sometimes you want to use diffenret modal presentation styles (for example overCurrentContext), in this case you can call setCustomModalTransition(customModalTransition: CustomModalTransition, inPresentationStyle: UIModalPresentationStyle) of UIViewController instead of setting customModalTransition directly.

More

You have different properties and methods to help you:

  • performDismissingTransition(interactive: Bool) to implement custom transition animation when dismissing
  • fromViewController/toViewController in term of Apple transition. They are reversed in presenting and dismissing transitions.
  • transitionContainerView view where the transition takes place (resentingViewController.view and presentedViewController.view located on inside transitionContainerView), so you can add your custom views here to make animation more interesting (see iOS Example)
  • Some methods for interactive animations (example will be added be soon)
  • Some method to work with orientation changing things (example will be added be soon)
You might also like...
Accessbility workshop by hacking with swift. Make every app more usefull for the all the users
Accessbility workshop by hacking with swift. Make every app more usefull for the all the users

Accessibility Accessbility workshop by hacking with swift. Make every app more u

LottieUI - A library developed to make Lottie easy to implement. It supports iOS and macOS

LottieUI It is a library developed to make Lottie easy to implement. It supports

A SwiftUI component to make handling of email links better.

EmailLink A SwiftUI component to make handling of email links better. Not only will EmailLink use the correct default client, it will also prompt 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

Ease is an event driven animation system that combines the observer pattern with custom spring animations as observers
Ease is an event driven animation system that combines the observer pattern with custom spring animations as observers

Ease is an event driven animation system that combines the observer pattern with custom spring animations as observers. It's magic. Features Animate a

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

SwiftUI project demonstrating Custom coded confetti animation for checkout page
SwiftUI project demonstrating Custom coded confetti animation for checkout page

Confetti-Checkout SwiftUI project demonstrating Custom coded confetti animation for checkout page NOTE: CAEmitterLayer is not used but all the confett

Custom MacBook keyboard backlight animations
Custom MacBook keyboard backlight animations

KBPulse Pulse the backlight on your Mac keyboard Demo Configuration Configuration files (.json) are stored in ~/Documents/KBPulse. (This location will

An experiment for using SwiftUI's custom timing Animation to create an orbital-like animation.
An experiment for using SwiftUI's custom timing Animation to create an orbital-like animation.

Orbital-SwiftUI-Animation An experiment for using SwiftUI's custom timing curve to create an orbital-like animation. How it looks: How it works: Apply

Comments
  • Example doesn't work

    Example doesn't work

    dyld: Library not loaded: @rpath/AZTransitions.framework/AZTransitions Referenced from: /var/containers/Bundle/Application/B3087059-617D-4269-85EC-8624CF68B164/iOS Example.app/iOS Example Reason: image not found

    opened by gerchicov-bp 1
  • fix an incorrect sentence in README explanation

    fix an incorrect sentence in README explanation

    I used this library to realize cool transition in my app. But at that time I found a little incorrect point in README.md, so I fixed it.

    func show() {
      let viewController = UIViewController()
      viewController.az_modalTransition = FashionTransition()
      self.present(viewController, animated: true, completion: nil)
    }
    

    to

    func show() {
      let viewController = UIViewController()
      viewController.customModalTransition = FashionTransition()
      self.present(viewController, animated: true, completion: nil)
    }
    
    opened by ngo275 0
Releases(0.23)
Owner
Alexander
Software Engineer, Product Manager
Alexander
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
Wave is a spring-based animation engine for iOS that makes it easy to create fluid, interruptible animations that feel great.

Wave is a spring-based animation engine for iOS and iPadOS. It makes it easy to create fluid, interactive, and interruptible animations that feel great.

Janum Trivedi 1.2k Jan 8, 2023
Garland View seamlessly transitions between multiple lists of content.

Garland View seamlessly transitions between multiple lists of content. We specialize in the designing and coding of custom UI for Mobile

Ramotion 504 Jul 31, 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
ViewAnimator brings your UI to life with just one line

ViewAnimator is a library for building complex iOS UIView animations in an easy way. It provides one line animations for any view included the ones wh

Marcos Griselli 6.9k Jan 2, 2023
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.

LoadingShimmer An easy way to add a shimmering effect to any view with just single line of code. It is useful as an unobtrusive loading indicator. Thi

Jogendra 1.4k Jan 6, 2023
A DSL to make animation easy on iOS with Swift.

This project is highly inspired by JHChainableAnimations, If you project is developed with Objective-C, use JHChainableAnimations instead. With DKChai

Draven 1.9k Dec 9, 2022
Presentation helps you to make tutorials, release notes and animated pages.

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

HyperRedink 3k Dec 28, 2022
CCMRadarView uses the IBDesignable tools to make an easy customizable radar view with animation

CCMRadarView CCMRadarView is a simple to use view that uses the new IBDesignable and IBInspectable features of XCode6 to easily configure the icon in

Carlos Compean 183 Sep 17, 2022
Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle.

Twinkle ✨ Twinkle is a Swift and easy way to make any UIView in your iOS or tvOS app twinkle. This library creates several CAEmitterLayers and animate

patrick piemonte 600 Nov 24, 2022