An analysis of-caanimation and catransition in animation

Source: Internet
Author: User

Source: http://blog.csdn.net/mad2man/article/details/17260887 now understand, to do animation. Need to use the Catransition Class! Then learn it! Put a starter code first!

[_imgpic setimage:image];//set a new picture

Catransition *animation = [catransition animation];

[Animation setduration:1.0];

[Animation setfillmode:kcafillmodeforwards];

[Animation Settimingfunction:[camediatimingfunctionfunctionwithname:kcamediatimingfunctioneaseout]];

[Animation settype:@ "Rippleeffect"];//rippleeffect

[Animation Setsubtype:kcatransitionfromtop];

[_imgpic.layer addanimation:animation Forkey:nil];

The realization function is, when Uiimageview changes the new picture, does the corresponding animation effect! So that, uiimageview conversion, not too monotonous! The first sentence, let me very confused! Catransition *animation = [catransition animation];+ (ID) Animation method creates a Catransition object. But Catransition has no animation method?!

@interface catransition:caanimation

So, Catransition is Caanimation's sub-class riding donkey to see libretto it! Caanimation classThe Caanimation class is an abstract class. Follow the camediatiming agreement and the Caaction protocol! CAAnimationis an abstract animation class. IT provides the basic support for the CAMediaTimingand CAActionProtocols.

Camediatiming protocol

You can adjust the time, including duration, speed, and repetition times.

Caaction protocol

Animations can be displayed in response to an action.

Caanimation has many derived classes

catransition provides a gradient effect: (Push and pull push effect, fade fade effect, uncover reveal effect).

caanimationgroup allows multiple animations to play simultaneously.

Cabasicanimation provides an implementation of a single animation.

cakeyframeanimation Key frame animation, you can define the course of action.

Caconstraint the constraint class, which is used in the layout manager class to set properties.

The caconstraintlayoutmanager constraint layout Manager is used to lay out multiple calayer. Each calayer is distinguished by name, and layout properties are set by Caconstraint.

catransaction Transaction class, you can modify the properties of multiple layers at the same time. It is divided into implicit transactions, and explicit transactions.

Caanimation Property

Delegate

The @property (retain) ID delegate sets the proxy for caanimation. The default is nil. Note: A caanimation instance cannot be set delegate to self. can cause circular references.

Removedoncompletion

@property (getter=isremovedoncompletion) BOOL removedoncompletion Sets whether the animation effect is removed from the set layer after the animation is complete. The default is yes. Timingfunction@property (retain) camediatimingfunction *timingfunction set the "timing" effect of the animation. is the animation of its own "rhythm": for example: Start fast, end time is slow, start slow, end times are fast, constant, etc., in the animation process of the "timing" effect. animation+ (ID) animation creates and returns a Caanimation instance. defaultvalueforkey+ (ID) Defaultvalueforkey: (NSString *) key returns the corresponding property value based on the attribute key. Caanimation instance Methodshouldarchivevalueforkey-(BOOL) Shouldarchivevalueforkey: (NSString *) key returns whether the specified property value can be archived. Key: The specified property. YES: Indicates that the attribute can be archived, no: cannot be archived. Caanimation Protocol Methodanimationdidstart-(void) Animationdidstart: (Caanimation *) The method that is executed when the animation begins theanimation. Theanimation: The Caanimation instance that is performing the animation. animationdidstop:finished-(void) Animationdidstop: (Caanimation *) Theanimation finished: (BOOL) This method is executed when the flag animation finishes or the animation is deleted for execution. Theanimation: Completed or deleted animation instance flag: Flag The animation is executed or deleted: yes: done; NO: deleted. It's just a blunt translation. caanimationClass. After all, the class is the parent class for other animations. Rest first! Fight again tomorrow!
    • Previous iOS Block-an analysis
    • An analysis of iOS animation-catransition

An analysis of-caanimation and catransition in animation

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.