Type Method

transitionFromView:toView:duration:options:completion:

Creates a transition animation between the specified views using the given parameters.

Declaration

+ (void)transitionFromView:(UIView *)fromView toView:(UIView *)toView duration:(NSTimeInterval)duration options:(UIViewAnimationOptions)options completion:(void (^)(BOOL finished))completion;

Parameters

fromView

The starting view for the transition. By default, this view is removed from its superview as part of the transition.

toView

The ending view for the transition. By default, this view is added to the superview of fromView as part of the transition.

duration

The duration of the transition animation, measured in seconds. If you specify a negative value or 0, the transition is made without animations.

options

A mask of options indicating how you want to perform the animations. For a list of valid constants, see UIViewAnimationOptions.

completion

A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished before the completion handler was called. If the duration of the animation is 0, this block is performed at the beginning of the next run loop cycle. This parameter may be NULL.

Discussion

This method provides a simple way to transition from the view in the fromView parameter to the view in the toView parameter. By default, the view in fromView is replaced in the view hierarchy by the view in toView. If both views are already part of your view hierarchy, you can include the UIViewAnimationOptionShowHideTransitionViews option in the options parameter to simply hide or show them.

This method modifies the views in their view hierarchy only. It does not modify your application’s view controllers in any way. For example, if you use this method to change the root view displayed by a view controller, it is your responsibility to update the view controller appropriately to handle the change.

The view transition starts immediately unless another animation is already in-flight, in which case it starts immediately after the current animation finishes.

During an animation, user interactions are temporarily disabled for the views being animated. (Prior to iOS 5, user interactions are disabled for the entire application.) If you want users to be able to interact with the views, include the UIViewAnimationOptionAllowUserInteraction constant in the options parameter.

See Also

Animating Views with Block Objects

+ animateWithDuration:delay:options:animations:completion:

Animate changes to one or more views using the specified duration, delay, options, and completion handler.

+ animateWithDuration:animations:completion:

Animate changes to one or more views using the specified duration and completion handler.

+ animateWithDuration:animations:

Animate changes to one or more views using the specified duration.

+ transitionWithView:duration:options:animations:completion:

Creates a transition animation for the specified container view.

+ animateKeyframesWithDuration:delay:options:animations:completion:

Creates an animation block object that can be used to set up keyframe-based animations for the current view.

+ addKeyframeWithRelativeStartTime:relativeDuration:animations:

Specifies the timing and animation values for a single frame of a keyframe animation.

+ performSystemAnimation:onViews:options:animations:completion:

Performs a specified system-provided animation on one or more views, along with optional parallel animations that you define.

+ animateWithDuration:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:

Performs a view animation using a timing curve corresponding to the motion of a physical spring.

+ performWithoutAnimation:

Disables a view transition animation.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software