IPhoneVariousAnimationThe implementation effect is what we will introduce in this article,IphoneThere are a lot of nice-lookingAnimationEffect, used for page switching, etc. Some of them are private to apple, and it is said that they cannot be approved by apple. Some of them have been used in recent work.AnimationSo I searched the documents online and learned about theseAnimation. Here, I will summarize my understanding. If there are any errors or omissions, please forgive me.
1. UIView Animation
In the official API, you can use UIView to set five animation effects:
- UIViewAnimationTransitionNone No animation is used
-
- UIViewAnimationTransitionFlipFromLeft
-
- UIViewAnimationTransitionFlipFromRight rotates the page from right to left, opposite to UIViewAnimationTransitionFlipFromLeft
-
- UIViewAnimationTransitionCurlUp page flip, from bottom up
-
- UIViewAnimationTransitionCurlDown page flip, top down
-
- For details, see UIViewAnimationTransition.
Example:
- [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 animation attribute change curve in the animation block. This method must be in the beginAnimations method and commitAnimations method. The default value is UIViewAnimationCurveEaseInOut.
- For details, see UIViewAnimationCurve.
-
- [UIView setAnimationRepeatAutoreverses: NO]; // sets whether to automatically reverse the current animation effect.
-
- [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView: self. view cache: YES];
- // Set the animated 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
2. Public animation effect
You can use CATransiton to set four animation effects:
- NSString * const kCATransitionFade; // gradually disappears
-
- NSString * const kCATransitionMoveIn; // overwrite
-
- NSString * const kCATransitionPush; // available
-
- NSString * const kCATransitionReveal; // opposite to MoveIn
Example:
- CATransition * animation = [CATransition animation];
-
- Animation. duration = 0.5f;
-
- Animation. timingFunction = UIViewAnimationCurveEaseInOut;
-
- Animation. type = kCATransitionPush; // set the above four animation Effects
-
- Animation. subtype = kCATransitionFromTop; // set the animation direction. There are four options,
-
- They are kCATransitionFromRight, kCATransitionFromLeft, kCATransitionFromTop, and kCATransitionFromBottom.
-
- [Self. view. layer addAnimation: animation forKey: @ "animationID"];
3. Private Animation
There are also many iphone animations that are private to Apple, such as photo deletion animations,
A private animation can be directly input into the animation string in animation. type. There are the following types of animations:
- Cube: flipped like a cube
-
- SuckEffect: scaled down, just like deleting a photo Animation
-
- OglFlip: up/down rotation. When the subType is fromLeft or fromRight,
- 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
See the http://www.cocoachina.com/bbs/read.php for the demo of all the above animation effects? Tid-11820.html, here to thank the landlord to share, to my learning has brought a lot of help.
UIViewAnimationState Description: http://www.iphonedevwiki.net/index.php/UIViewAnimationState
At the same time, I encountered a problem when using UIView to implement suckEffect reduction. I don't know how to locate the problem). After searching, I found the solution as follows:
- [UIView beginAnimations:@"suck" context:NULL];
- [UIView setAnimationTransition:103 forView:self.view cache:YES];
- [UIView setAnimationDuration:0.5f];
- if (self.interfaceOrientation == UIInterfaceOrientationPortrait || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
- {
- [UIView setAnimationPosition:CGPointMake(44, 42)];
- }else {
- [UIView setAnimationPosition:CGPointMake(320 , 42)];
- }
- [UIView commitAnimations];
The setAnimationPosition method is used to set the position of the zoom-in point. Although a warning is reported here, the result is correct.
Summary: DetailsIPhoneVariousAnimationThe content of the implementation effect is introduced. I hope this article will help you!