Detailed description of various animation effects in iPhone Development

Source: Internet
Author: User

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:

 
 
  1. UIViewAnimationTransitionNone No animation is used
  2.  
  3. UIViewAnimationTransitionFlipFromLeft
  4.  
  5. UIViewAnimationTransitionFlipFromRight rotates the page from right to left, opposite to UIViewAnimationTransitionFlipFromLeft
  6.  
  7. UIViewAnimationTransitionCurlUp page flip, from bottom up
  8.  
  9. UIViewAnimationTransitionCurlDown page flip, top down
  10.  
  11. For details, see UIViewAnimationTransition.

Example:

 
 
  1. [UIView beginAnimations: @ "animationID" context: nil]; // starts an animation block. The first parameter is the animation block identifier.
  2.  
  3. [UIView setAnimationDuration: 0.5f]; // sets the animation duration.
  4.  
  5. [UIView setAnimationCurve: UIViewAnimationCurveEaseInOut];
  6. // 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.
  7. For details, see UIViewAnimationCurve.
  8.  
  9. [UIView setAnimationRepeatAutoreverses: NO]; // sets whether to automatically reverse the current animation effect.
  10.  
  11. [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView: self. view cache: YES];
  12. // Set the animated Effect of transition. The first parameter can use the preceding five animation effects.
  13.  
  14. [Self. view exchangeSubviewAtIndex: 1 withSubviewAtIndex: 0]; // page flip
  15.  
  16. [UIView commitAnimations]; // submit an animation

2. Public animation effect

You can use CATransiton to set four animation effects:

 
 
  1. NSString * const kCATransitionFade; // gradually disappears
  2.  
  3. NSString * const kCATransitionMoveIn; // overwrite
  4.  
  5. NSString * const kCATransitionPush; // available
  6.  
  7. NSString * const kCATransitionReveal; // opposite to MoveIn

Example:

 
 
  1. CATransition * animation = [CATransition animation];
  2.  
  3. Animation. duration = 0.5f;
  4.  
  5. Animation. timingFunction = UIViewAnimationCurveEaseInOut;
  6.  
  7. Animation. type = kCATransitionPush; // set the above four animation Effects
  8.  
  9. Animation. subtype = kCATransitionFromTop; // set the animation direction. There are four options,
  10.  
  11. They are kCATransitionFromRight, kCATransitionFromLeft, kCATransitionFromTop, and kCATransitionFromBottom.
  12.  
  13. [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:

 
 
  1. Cube: flipped like a cube
  2.  
  3. SuckEffect: scaled down, just like deleting a photo Animation
  4.  
  5. OglFlip: up/down rotation. When the subType is fromLeft or fromRight,
  6. Same as UIViewAnimationTransitionFlipFromLeft and UIViewAnimationTransitionFlipFromRight
  7.  
  8. RippleEffect: Water Wave Effect
  9.  
  10. PageCurl: Same as UIViewAnimationTransitionCurlUp
  11.  
  12. PageUnCurl: Same as UIViewAnimationTransitionCurlDown
  13.  
  14. CameraIrisHollowOpen: First half of cameraIris.
  15.  
  16. 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:

 
 
  1. [UIView beginAnimations:@"suck" context:NULL];  
  2. [UIView setAnimationTransition:103 forView:self.view cache:YES];  
  3. [UIView setAnimationDuration:0.5f];  
  4. if (self.interfaceOrientation  == UIInterfaceOrientationPortrait || self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) 
  5. {  
  6.  [UIView setAnimationPosition:CGPointMake(44, 42)];  
  7. }else {  
  8. [UIView setAnimationPosition:CGPointMake(320 , 42)];  
  9. }  
  10. [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!

Related Article

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.