In iPhone development, we often need to perform animation switching between different pages, which looks better. There are three basic animations:
1. UIView
UIView provides five official animation effects for you:
UIViewAnimationTransitionNone does not use the animation rotate from left to right to flip pages. The opposite is UIViewAnimationTransitionCurlUp, and UIViewAnimationTransitionCurlDown.
Example:
View plain
[UIView beginAnimations: @ "animationID" context: nil]; // starts an animation block. The first parameter is the animation block identifier.
[UIView setAnimationDuration: 0.5f]; // sets the animation duration.
[UIView setAnimationCurve: UIViewAnimationCurveEaseInOut]; // set the curves of animation attribute changes in the animation block. This method must be used in the beginAnimations method and commitAnimations method. The default value is uiviewanimationcurveeas. For details, see UIViewAnimationCurve.
[UIView setAnimationRepeatAutoreverses: NO]; // sets whether to automatically reverse the current animation effect.
[UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView: self. view cache: YES]; // sets the animation effect of transition. The first parameter can use the preceding five animation effects.
[Self. view exchangeSubviewAtIndex: 1 withSubviewAtIndex: 0]; // page flip
[UIView commitAnimations]; // submit an animation
In this way, we can make the UIView page jump between pages through animation.
2. CATransiton
CATransiton provides four types of animation effects:
NSString * const kCATransitionFade; // gradually disappears
NSString * const kCATransitionMoveIn; // overwrite
NSString * const kCATransitionPush; // available
NSString * const kCATransitionReveal; // opposite to MoveIn
Example:
View plain
CATransition * animation = [CATransition animation]; // initialize the animation
Animation. duration = 0.5f; // Interval
Animation. timingFunction = UIViewAnimationCurveEaseInOut;
Animation. type = kCATransitionPush; // set the above four animation Effects
Animation. subtype = kCATransitionFromTop; // set the animation direction. There are four options: kCATransitionFromRight, kCATransitionFromLeft, kCATransitionFromTop, and kCATransitionFromBottom.
[Self. view. layer addAnimation: animation forKey: @ "animationID"];
3. Private Animation
The private animation is based on the UIView and sets the animation. type. You can provide the following options:
Cube: flipped like a cube
SuckEffect: scaled down, just like the animation used to delete a photo
OglFlip: up/down rotation. When the subType is fromLeft or fromRight, it is the same as UIViewAnimationTransitionFlipFromLeft and UIViewAnimationTransitionFlipFromRight.
RippleEffect: Water Wave Effect
PageCurl: Same as UIViewAnimationTransitionCurlUp
PageUnCurl: Same as UIViewAnimationTransitionCurlDown
CameraIrisHollowOpen: First half of cameraIris.
CameraIrisHollowClose: Second half of cameraIris
Add the source code of an animation for your reference. The animation effect will be introduced here today. Thank you.
This is because the code sent to csdn failed to be viewed and uploaded to another place. Forgive me
Attachment: http://www.bkjia.com/uploadfile/2011/1122/20111122043352873.rar
Author andy-Qingfeng