Detailed description of IPhone animation effect types and implementation methods

Source: Internet
Author: User

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

 
 
  1. CGContextRef context = UIGraphicsGetCurrentContext ();
  2. [UIView beginAnimations: nil context: context];
  3. [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
  4. [UIView setAnimationDelegate: self];
  5. [UIView setAnimationDuration: 1.0]; // animation duration
  6.  
  7. // Add the code you have changed to the UIView.
  8.  
  9. // [UIView setAnimationDidStopSelector: @ selector (animationFinished :)]; // After the animation is stopped, execute a method
  10. [UIView commitAnimations];

2. UIView (using Cocoa Touch)

 
 
  1. CGContextRef context = UIGraphicsGetCurrentContext ();
  2. [UIView beginAnimations: nil context: context];
  3. [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
  4. [UIView setAnimationDuration: 1.0];
  5.  
  6. // Cocoa Touch
  7. [UIView setAnimationTransition: UIViewAnimationTransitionCurlUp forView: myView cache: YES];
  8.  
  9. [UIView setAnimationDelegate: self];
  10. // [UIView setAnimationDidStopSelector: @ selector (animationFinished :)]; // After the animation is stopped, execute a method
  11. [UIView commitAnimations];
  12. Animation Mode UIViewAnimationTransition ):
  13. UIViewAnimationTransitionFlipFromLeft // flip from left to right
  14. UIViewAnimationTransitionFlipFromRight // flip from right to left
  15. UIViewAnimationTransitionCurlUp // page flip from bottom to top
  16. UIViewAnimationTransitionCurlDown // page flip from top to bottom

3. CATransition

 
 
  1. CATransition * animation = [CATransition animation];
  2. Animation. delegate = self;
  3. Animation. duration = 1.0f; // animation execution time
  4. Animation. timingFunction = UIViewAnimationCurveEaseInOut;
  5. Animation. type = kCATransitionFade;
  6. Animation. subtype = kCATransitionFromRight;
  7. // Add the code you have changed to the UIView.
  8.  
  9. [[MyView layer] addAnimation: animation forKey: @ "animation"];

SetType: There are four types:

 
 
  1. KCATransitionFade // cross fade transition
  2. KCATransitionMoveIn // move to overwrite the source Image
  3. KCATransitionPush // New View releases old view
  4. KCATransitionReveal // display at the bottom

SetSubtype: There are four types:

 
 
  1. KCATransitionFromRight;
  2. KCATransitionFromLeft (default)
  3. KCATransitionFromTop;
  4. KCATransitionFromBottom
  5. Note: kCATransitionFade does not support Subtype.

4. CATransition only uses setType and the parameter is NSString)

 
 
  1. CATransition * animation = [CATransition animation];
  2. Animation. delegate = self;
  3. Animation. duration = 1.0f; // animation execution time
  4. Animation. timingFunction = UIViewAnimationCurveEaseInOut;
  5. Animation. type = @ "suckEffect"; // Add the code you have changed to the UIView.
  6. [[MyView layer] addAnimation: animation forKey: @ "animation"];

The following functions can be used:

 
 
  1. PageCurl // page up
  2. PageUnCurl // flip down one page
  3. RippleEffect // drip Effect
  4. SuckEffect // contraction effect, such as a piece of cloth being extracted
  5. Cube // cube Effect
  6. OglFlip // up/down flip Effect

Summary: DetailsIPhone AnimationThe effect type and implementation method are described. I hope this article will help you!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.