Protocol

UIView​Controller​Animated​Transitioning

Adopt the UIView​Controller​Animated​Transitioning protocol in objects that implement the animations for a custom view controller transition. The methods in this protocol let you define an animator object, which creates the animations for transitioning a view controller on or off screen in a fixed amount of time. The animations you create using this protocol must not be interactive. To create interactive transitions, you must combine your animator object with another object that controls the timing of your animations.

Overview

In your animator object, implement the transition​Duration(using:​) method to specify the duration of your transition and implement the animate​Transition(using:​) method to create the animations themselves. Information about the objects involved in the transition is passed to your animate​Transition(using:​) method in the form of a context object. Use the information provided by that object to move the target view controller’s view on or off screen over the specified duration.

Create your animator object from a transitioning delegate—an object that conforms to the UIView​Controller​Transitioning​Delegate protocol. When presenting a view controller, set the presentation style to custom and assign your transitioning delegate to the view controller’s transitioning​Delegate property. The view controller retrieves your animator object from the transitioning delegate and uses it to perform the animations. You can provide separate animator objects for presenting and dismissing the view controller.

To add user interaction to a view controller transition, you must use an animator object together with an interactive animator object—a custom object that adopts the UIView​Controller​Interactive​Transitioning protocol. For more on defining interactive transitions, see UIView​Controller​Interactive​Transitioning.

Symbols

Performing a Transition

func animate​Transition(using:​ UIView​Controller​Context​Transitioning)

Tells your animator object to perform the transition animations.

func animation​Ended(Bool)

Tells your animator object that the transition animations have finished.

Reporting Transition Duration

func transition​Duration(using:​ UIView​Controller​Context​Transitioning?)

Asks your animator object for the duration (in seconds) of the transition animation.

Relationships

Inherits From