iOS Animation - UIView.TransitionWithView
Learning notes for book iOS Animations by Tutorials.
First, what is the difference between transitionWithView
and animationWithDuration
?animateWithDuration
animates a UIView through changing its properties, whereas transitionWithView
allows you to apply a transition to the specified view so that you can make state changes to it, such as add, remove, hide, show and replace one view with another view.
Then, here is an example. We added a hidden logging status view to the root view. After clicked the Login button, we show the status view. After 1.5 seconds, we hide the status view and refresh to the next status.
The code looks like this:
1 | showMessage() { |
The first parameter in transitionWithView()
is the container view that performs the transition (Here is the status view). The rest of parameters are quite similar to the animateWithDuration()
.
Transition option:
- .TransitionFlipFromLeft
- .TransitionFlipFromRight
- .TransitionCurlUp
- .TransitionCurlDown
- .TransitionCrossDissolve
- .TransitionFlipFromTop
- .TransitionFlipFromBottom