UIPercentDrivenInteractiveTransition Class Reference

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

Overview

A percent-driven interactive transition object drives the custom animation between the disappearance of one view controller and the appearance of another. It relies on a transition animator delegate—a custom object that adopts the UIViewControllerAnimatorTransitioning protocol—to set up and perform the animations.

To use this concrete class, return an instance of it from your view controller delegate when asked for an interactive transition controller. As user events arrive that would affect the progress of a transition, call the updateInteractiveTransition:, cancelInteractiveTransition, and finishInteractiveTransition methods to reflect the current progress. For example, you might call these methods from a gesture recognizer to reflect how much of the gesture is completed.

You can subclass UIPercentDrivenInteractiveTransition, but if you do so you must start each of your method overrides with a call to the super implementation of the method.

Tasks

Accessing Transition Attributes

Managing a Transition

Properties

completionCurve

Indicates the animation completion curve for an interactive transition.

@property(nonatomic, assign) UIViewAnimationCurve completionCurve
Discussion

When the interactive part of a view controller transition is complete, you can set this property to indicate a desired animation completion curve. Default value is UIViewAnimationCurveEaseInOut.

During the interactive portion of a view controller transition, the animation curve is linear.

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

completionSpeed

The speed of the transition animation.

@property(nonatomic, assign) CGFloat completionSpeed
Discussion

The default value of this property is 1.0, which yields an animation that proceeds in real time. You typically change this value to speed up or slow down the animation at specific points in the transition. For example, you might change the animation speed at the end of a transition or when canceling it, in which case you would set the speed when you stop tracking user events and are about to call the cancelInteractiveTransition or finishInteractiveTransition method.

The speed acts as a multiplier to the current animation speed, so values greater than 1.0 speed up the animation and values less than 1.0 slow it down. The value in this property must always be greater than 0.0.

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

duration

The overall duration (in seconds) of the transition animation. (read-only)

@property(readonly) CGFloat duration
Discussion

This property reflects the duration of the transition animation if it were to occur without user interactions. It is obtained from the standard animator object returned by your delegate. The actual duration can vary depending on the user interactions you are tracking and responding to.

Availability
  • Available in iOS 7.0 and later.
See Also
  • transitionDuration:
Declared In
UIViewControllerTransitioning.h

percentComplete

The amount of the transition (specified as a percentage of the overall duration) that is complete. (read-only)

@property(readonly) CGFloat percentComplete
Discussion

The value in this property reflects the last value passed to the updateInteractiveTransition: method.

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

Instance Methods

cancelInteractiveTransition

Notifies the system that user interactions canceled the transition.

- (void)cancelInteractiveTransition
Discussion

This is a convenience method that calls through to the cancelInteractiveTransition method of the context object.

While tracking user interactions, your gesture recognizer or event-handling code would call this method when interactions suggest that the user wants to cancel or abort the view controller transition. For example, if the user reverses the swipe direction and then touch events end, suggesting that the user decided against the transition, you would call this method.

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

finishInteractiveTransition

Notifies the system that user interactions signaled the completion of the transition.

- (void)finishInteractiveTransition
Discussion

This is a convenience method that calls through to the finishInteractiveTransition method of the context object.

While tracking user interactions, your gesture recognizer or event-handling code should call this methods when the interactions suggest that the transition is now complete. For example, if the user swipes a finger, and the touch events indicate that the swipe distance crossed the threshold needed to complete the gesture, call this method when the corresponding touch events end to let the system know that it can now complete the transition.

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

updateInteractiveTransition:

Updates the completion percentage of the transition.

- (void)updateInteractiveTransition:(CGFloat)percentComplete
Parameters
percentComplete

The percentage of the transition that is currently complete, specified as a floating-point number in the range 0.0 to 1.0. If you specify a value less than 0.0, this method changes it to 0.0. Specifying a value greater than 1.0 would cause the animation to appear complete already.

Discussion

This is a convenience method that calls through to the updateInteractiveTransition: method of the context object.

While tracking user events, your code should call this method regularly to update the current progress toward completing the transition. If, during tracking, the interactions cross a threshold that you consider signifies the completion or cancellation of the transition, stop tracking events and call the finishInteractiveTransition or cancelInteractiveTransition method.

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