DetailsIPhone AnimationThe effect type and implementation method are described in this article.IphoneMediumAnimationLet's look at the content together.
ImplementationIphonePrettyAnimationThere are two main effects: UIView and CATransition.
1. UIView
- CGContextRef context = UIGraphicsGetCurrentContext ();
- [UIView beginAnimations: nil context: context];
- [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
- [UIView setAnimationDelegate: self];
- [UIView setAnimationDuration: 1.0]; // animation duration
-
- // Add the code you have changed to the UIView.
-
- // [UIView setAnimationDidStopSelector: @ selector (animationFinished :)]; // After the animation is stopped, execute a method
- [UIView commitAnimations];
2. UIView (using Cocoa Touch)
- CGContextRef context = UIGraphicsGetCurrentContext ();
- [UIView beginAnimations: nil context: context];
- [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
- [UIView setAnimationDuration: 1.0];
-
- // Cocoa Touch
- [UIView setAnimationTransition: UIViewAnimationTransitionCurlUp forView: myView cache: YES];
-
- [UIView setAnimationDelegate: self];
- // [UIView setAnimationDidStopSelector: @ selector (animationFinished :)]; // After the animation is stopped, execute a method
- [UIView commitAnimations];
- Animation Mode UIViewAnimationTransition ):
- UIViewAnimationTransitionFlipFromLeft // flip from left to right
- UIViewAnimationTransitionFlipFromRight // flip from right to left
- UIViewAnimationTransitionCurlUp // page flip from bottom to top
- UIViewAnimationTransitionCurlDown // page flip from top to bottom
3. CATransition
- CATransition * animation = [CATransition animation];
- Animation. delegate = self;
- Animation. duration = 1.0f; // animation execution time
- Animation. timingFunction = UIViewAnimationCurveEaseInOut;
- Animation. type = kCATransitionFade;
- Animation. subtype = kCATransitionFromRight;
- // Add the code you have changed to the UIView.
-
- [[MyView layer] addAnimation: animation forKey: @ "animation"];
SetType: There are four types:
- KCATransitionFade // cross fade transition
- KCATransitionMoveIn // move to overwrite the source Image
- KCATransitionPush // New View releases old view
- KCATransitionReveal // display at the bottom
SetSubtype: There are four types:
- KCATransitionFromRight;
- KCATransitionFromLeft (default)
- KCATransitionFromTop;
- KCATransitionFromBottom
- Note: kCATransitionFade does not support Subtype.
4. CATransition only uses setType and the parameter is NSString)
- CATransition * animation = [CATransition animation];
- Animation. delegate = self;
- Animation. duration = 1.0f; // animation execution time
- Animation. timingFunction = UIViewAnimationCurveEaseInOut;
- Animation. type = @ "suckEffect"; // Add the code you have changed to the UIView.
- [[MyView layer] addAnimation: animation forKey: @ "animation"];
The following functions can be used:
- PageCurl // page up
- PageUnCurl // flip down one page
- RippleEffect // drip Effect
- SuckEffect // contraction effect, such as a piece of cloth being extracted
- Cube // cube Effect
- OglFlip // up/down flip Effect
Summary: DetailsIPhone AnimationThe effect type and implementation method are described. I hope this article will help you!