UIViewControllerAnimatedTransitioning Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 7.0 and later.
Declared in
UIViewControllerTransitioning.h

Overview

To define the animation for a custom view controller transition, configure a custom class to adopt the UIViewControllerAnimatedTransitioning protocol. The resulting animated transitioning delegate provides a fixed-duration, noninteractive, custom animation between view controllers.

Implement your animation in the animateTransition: method and specify its duration in the the transitionDuration: method.

To add user interaction to an animated transition, employ an interactive transition delegate—a custom object that adopts the UIViewControllerInteractiveTransitioning protocol. For more on defining an interactive transition, see UIViewControllerInteractiveTransitioning Protocol Reference.

Tasks

Performing a Transition

Reporting Transition Duration

Instance Methods

animateTransition:

Performs a custom view controller transition animation. (required)

- (void)animateTransition:(id<UIViewControllerContextTransitioning>)transitionContext
Parameters
transitionContext

The context object containing information about the transition.

Discussion

To configure the animation for a view controller transition, implement this method by specifying Core Animation-based animations of the views of the view controllers involved in the transition.

Use the viewControllerForKey: method on the transitionContext parameter value to obtain references to the transition’s from and to view controllers. This method, and other methods of the UIViewControllerContextTransitioning protocol, are described in UIViewControllerContextTransitioning Protocol Reference.

Because UIKit views always have an underlying layer object, employing view-based animations or using Core Animation APIs both modify the layer objects appropriately for animated transitions.

If you want to draw to the screen directly without a view, instead configure a CADisplayLink object.

Availability
  • Available in iOS 7.0 and later.
Declared In
UIViewControllerTransitioning.h

animationEnded:

Called when the animation has ended.

- (void)animationEnded:(BOOL)transitionCompleted
Parameters
transitionCompleted

Contains the value YES if the transition completed successfully and the new view controller is now displayed or NO if the transition was canceled and the original view controller is still visible.

Discussion

Use this method to perform any final cleanup operations required by your transition animator when the transition finishes.

Availability
  • Available in iOS 7.0 and later.
Declared In
UIViewControllerTransitioning.h

transitionDuration:

Called when the system needs the duration, in seconds, of the transition animation. (required)

- (NSTimeInterval)transitionDuration:(id<UIViewControllerContextTransitioning>)transitionContext
Parameters
transitionContext

The context object containing information to use during the transition.

Return Value

The duration, in seconds, of your custom transition animation.

Discussion

The system calls this method when another object needs to synchronize its actions with your custom animation. For example, a navigation controller calls transitionDuration: so it can synchronize the movement of the corresponding navigation bar.

When determining the value to return, assume there will be no user interaction during the transition—even if you plan to support user interactions at runtime.

Availability
  • Available in iOS 7.0 and later.
Declared In
UIViewControllerTransitioning.h