Transitions

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

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.

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)

Last updated