IPhone application development day 11: three types of typical animations

Source: Internet
Author: User

 

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

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.