iOS Developer Library

Developer

UIKit Framework Reference UIViewControllerTransitionCoordinatorContext Protocol Reference

Options
Deployment Target:

On This Page
Language:

UIViewControllerTransitionCoordinatorContext

Inherits From


Not Applicable

Import Statement


Swift

import UIKit

Objective-C

@import UIKit;

Availability


Available in iOS 7.0 and later

An object that conforms to the UIViewControllerTransitionCoordinatorContext protocol provides information about an in-progress view controller transition. Do not adopt this protocol in your own classes. UIKit creates an object that adopts this protocol and makes it available to your code when you animate changes using a transition coordinator object.

A transition coordinator context provides most of the same information as an object that adopts the UIViewControllerContextTransitioning protocol. You use this contextual information to determine the animation parameters, such as the view in which the animations take place, whether the transition is interactive, or whether the transition was the result of an interface orientation change. You then apply that information to the animations you create.

Most animations take place in the view returned by the containerView method. And at the time your animation blocks are executed, the view hierarchy already contains the view of the from view controller. You can use your animation blocks to animate additional content in that same container view or you can animate content in an entirely different view.

  • Returns the view controllers involved in the transition. (required)

    Declaration

    Swift

    func viewControllerForKey(_ key: String) -> UIViewController!

    Objective-C

    - (UIViewController *)viewControllerForKey:(NSString *)key

    Parameters

    key

    The key indicating which view controller you want. For a list of possible values, see ”View Controller Transition Keys” constants in UIViewControllerContextTransitioning Protocol Reference.

    Return Value

    The view controller associated with the key.

    Discussion

    The view controller associated with the UITransitionContextFromViewControllerKey key corresponds to the view controller that is already onscreen. The view controller associated with the UITransitionContextToViewControllerKey key corresponds to the view controller that is to be animated onscreen.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later

  • Returns the specified view involved in the transition. (required)

    Declaration

    Swift

    func viewForKey(_ key: String) -> UIView?

    Objective-C

    - (UIView *)viewForKey:(NSString *)key

    Parameters

    key

    The key identifying the view you want. For a list of possible keys, see “View Transition Keys” constants in UIViewControllerContextTransitioning Protocol Reference.

    Return Value

    The view object for the specified key or nil if the view could not be found.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later

  • Returns the view in which the transition takes place. (required)

    Declaration

    Swift

    func containerView() -> UIView

    Objective-C

    - (UIView *)containerView

    Return Value

    The container view for the transition animation.

    Discussion

    The container view acts as the host view for any animations between the transitioning view controllers. When animating your own custom views, add them to the container view if you want them to interoperate with the view controllers’ views.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later

  • Returns the presentation style being used for the transition. (required)

    Declaration

    Swift

    func presentationStyle() -> UIModalPresentationStyle

    Objective-C

    - (UIModalPresentationStyle)presentationStyle

    Return Value

    The modal presentation style associated with the transition or UIModalPresentationNone if the transition is not a modal presentation or dismissal. For a list of possible values, see “Modal Presentation Styles” in UIViewController Class Reference.

    Discussion

    When presenting or dismissing a view controller modally, this method returns the presentation style used for that transition. For interface rotations and other events that do not involve a specific transition between view controllers, this method returns UIModalPresentationNone.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later

  • Returns the noninteractive duration of a transition. (required)

    Declaration

    Swift

    func transitionDuration() -> NSTimeInterval

    Objective-C

    - (NSTimeInterval)transitionDuration

    Return Value

    The expected duration, in seconds, of the view controller transition, if it proceeds noninteractively.

    Discussion

    The transition duration defines the time for the main transition to finish. Use this value when configuring your own animations if you want them to end at the same time as the main transition.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later

  • Returns the completion curve associated with the transition. (required)

    Declaration

    Swift

    func completionCurve() -> UIViewAnimationCurve

    Objective-C

    - (UIViewAnimationCurve)completionCurve

    Return Value

    The completion curve for the view controller transition. For a list of possible values, see the UIViewAnimationCurve type.

    Discussion

    The completion curve defines the timing of the animations. For interactive transitions, this value is usually obtained from the completionCurve property of the interactive animator object. Use this value when configuring your own animations if you want the same timing as the main transition.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later

  • Returns the starting velocity to use for any final animations. (required)

    Declaration

    Swift

    func completionVelocity() -> CGFloat

    Objective-C

    - (CGFloat)completionVelocity

    Return Value

    The completion velocity for the view controller transition. A value of 1.0 corresponds to an animation that would complete in the duration returned by the transitionDuration method. Higher values cause the animations to move faster by the corresponding factor and lower values cause it to move slower. The value of this property is always greater than 0.0.

    Discussion

    The completion velocity provides the starting speed to use at the end of an interactive animation. Setting the initial speed of your animations ensures that views do not change velocity abruptly. This value is usually obtained from the completionVelocity property of the interactive animator object.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later

  • Returns the percentage of completion for an interactive transition when it moves to its noninteractive phase. (required)

    Declaration

    Swift

    func percentComplete() -> CGFloat

    Objective-C

    - (CGFloat)percentComplete

    Return Value

    The percentage of completion when an interactive transition moves to its noninteractive completion phase.

    Discussion

    Use this value to determine how much of the interactive transition completed before the transition was canceled or moved to its final animations.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later

  • Returns a Boolean value indicating whether the transition started as an interactive transition. (required)

    Declaration

    Swift

    func initiallyInteractive() -> Bool

    Objective-C

    - (BOOL)initiallyInteractive

    Return Value

    YEStrue when the transition was initiated interactively and the isAnimated method also returns YEStrue; otherwise NOfalse.

    Discussion

    The value returned by this method does not change during the course of a transition. To determine whether the transition is currently interactive, use the isInteractive method instead.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later

  • Returns a Boolean value indicating whether the transition is animated. (required)

    Declaration

    Swift

    func isAnimated() -> Bool

    Objective-C

    - (BOOL)isAnimated

    Return Value

    YEStrue when the transition is explicitly animated or when the transition uses the UIModalPresentationCustom presentation type; otherwise, NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later

  • Returns a Boolean value indicating whether an interactive transition was canceled. (required)

    Declaration

    Swift

    func isCancelled() -> Bool

    Objective-C

    - (BOOL)isCancelled

    Return Value

    YEStrue when an interactive transition is ending because the user canceled the transition; otherwise NOfalse.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later

  • Returns a Boolean value indicating whether the transition is currently interactive. (required)

    Declaration

    Swift

    func isInteractive() -> Bool

    Objective-C

    - (BOOL)isInteractive

    Return Value

    YEStrue if a transition is currently interactive or NOfalse if it is not.

    Discussion

    This method returns the current interactive status of a view controller transition. Every interactive transition has at least one noninteractive segment—namely, when it is completing. In addition, you can design an interactive transition to have intermediate segments that are noninteractive.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 7.0 and later

  • Returns a transform indicating the amount of rotation being applied during the transition. (required)

    Declaration

    Swift

    func targetTransform() -> CGAffineTransform

    Objective-C

    - (CGAffineTransform)targetTransform

    Return Value

    An affine transform indicating the amount of rotation being applied to the interface. This transform is the identity transform when no rotation is applied; otherwise, it is a transform that applies a 90 degree, -90 degree, or 180 degree rotation.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 8.0 and later