mskw
mskw

Reputation: 10348

Difference with TransisitionWithView and AnimationWithDuration

I can pretty much do everything TransistionWithView can do with AnimationWithDuration. I'm really not sure when there is a use case to just one over the other.

What are the use case to use TransitionWithView over AnimateWithDuration?

Upvotes: 1

Views: 137

Answers (1)

Ian MacDonald
Ian MacDonald

Reputation: 14030

[UIView transitionWithView:] allows animating actions that aren't restricted to modifying values of animatable properties. For example:

[UIView transitionWithView:containerView
                  duration:0.2
                   options:UIViewAnimationOptionTransitionFlipFromLeft
                animations:^{ [fromView removeFromSuperview]; [containerView addSubview:toView]; }
                completion:NULL];

This allows you to animate the addition, removal, showing, or hiding of subviews where [UIView animateWithDuration:animations:] only animates value changes for animatable properties.

Upvotes: 3

Related Questions