Motion
  • Introduction
  • Overview
    • Motion
    • Transitions
    • Animations
    • Installation
    • Change Log
  • API
    • MotionTransition
    • MotionAnimation
Powered by GitBook
On this page
  • Example Usage
  • UINavigationController, UITabBarController, and UIViewController Transitions
  • Example Usage
  1. Overview

Transitions

PreviousMotionNextAnimations

Last updated 7 years ago

Motion transitions a source view to a destination view using a linking identifier property named motionIdentifier.

Match

Translate

Rotate

Arc

Scale

Example Usage

An example of transitioning from one view controller to another with transitions:

View Controller 1

greyView.motionIdentifier = "foo"
orangeView.motionIdentifier = "bar"

View Controller 2

isMotionEnabled = true
greyView.motionIdentifier = "foo"
orangeView.motionIdentifier = "bar"
orangeView.transition(.translate(x: -100))

The above code snippet tells the source views in view controller 1 to link to the destination views in view controller 2 using the motionIdentifier. Animations may be added to views during a transition using the transition method. The transition method accepts MotionTransition structs that configure the view's animation.

UINavigationController, UITabBarController, and UIViewController Transitions

Motion offers default transitions that may be used by UINavigationControllers, UITabBarControllers, and presenting UIViewControllers.

Push

Slide

ZoomSlide

Cover

Page

Fade

Zoom

Example Usage

An example of transitioning from one view controller to another using a UINavigationController with a zoom transition:

UINavigationController

class AppNavigationController: UINavigationController {
    open override func viewDidLoad() {
        super.viewDidLoad()
        isMotionEnabled = true
        motionNavigationTransitionType = .zoom
    }
}

To add an automatic reverse transition, use autoReverse.

motionNavigationTransitionType = .autoReverse(presenting: .zoom)

MotionTransition API
Code Samples
Code Samples
Rotate
Translate
Slide
Match
Scale
Zoom Slide
Arc
Push
Page
Cover
Fade
Zoom