Coreanimation (Calayer animation)

Source: Internet
Author: User

Coreanimation Basic Introduction:

    • Coreanimation animations on the media layer of the iOS framework
    • Coreanimation animation implementation needs to add Quartzcore.framework
    • Coreanimation is basically layeranimation.

Coreanimation classification:

Coreanimation Effect:

Coreanimation

Calayer Basic Introduction

Common Properties of Calayer

Cabasicanimation

Cakeyframeanimation

Caanimationgroup

Caspringanimation

Xib sets several button and then associates the method, code shows:

1 @interfaceViewcontroller ()2@property (Weak, nonatomic) Iboutlet Uiimageview *ImageView;3 4 @end5 6 @implementationViewcontroller7 #pragmaMark-cabasicanimation8-(Ibaction) Cabasicanimation: (ID) Sender {9     //First step: Create an Animated objectTenCabasicanimation *basicanimation =[cabasicanimation animation]; One     //Step Two: Tell the layer what kind of animation you need to perform (the content behind the Calayer is set to the relevant properties) ABasicanimation.keypath =@"position";//position change position. -     //Step Three: Tell the layer where to come from and where to go -Basicanimation.fromvalue = [Nsvalue valuewithcgpoint:cgpointmake ( -, -)]; theBasicanimation.tovalue = [Nsvalue valuewithcgpoint:cgpointmake ( -, -)]; -     //Note: If you want to implement the picture will not go to the original point, you need the following two lines of code -Basicanimation.removedoncompletion =NO; -     //set content to save animation state +Basicanimation.fillmode =kcafillmodeforwards; -      +     //Fourth Step: Set how long the animation lasts ABasicanimation.duration =6.0f; at     //Fifth Step: Add the animations you want to perform on Calayer -[Self.imageView.layer addanimation:basicanimation Forkey:@"Basic"]; -     //************* Rollover Effect -Cabasicanimation *basic =[cabasicanimation animation]; -Basic.keypath =@"Transform"; -     //set the place to flip inBasic.tovalue = [Nsvalue valuewithcatransform3d:catransform3dmakerotation (M_pi_2,0,0,1)]; -Basic.duration =0.2f; to[Self.imageView.layer addanimation:basic Forkey:@"AAAA"]; +     //to remove an animation from a key -     //[Self.imageView.layer removeanimationforkey:@ "Basic"]; the } *  $ #pragmaMark-cakeyframeanimationPanax Notoginseng-(Ibaction) Cakeyanimation: (ID) Sender { -     //First step: Create an Object theCakeyframeanimation *keyanimation =[cakeyframeanimation animation]; +     //Step Two: Set the animation track AKeyanimation.keypath =@"transform.rotation"; the     //Step Three: Set the angle of the rollover (Radian Calculation formula: Degree/180*M_PI) +Keyanimation.values = @[@ (- -/180.0* m_pi), @ ( -/180.0* m_pi), @ (- the/180.0*M_pi)]; -     //Fourth Step: Set the length of time $Keyanimation.duration =15.0f; $     //Fifth Step: Add animations to layer layers -[Self.view.layer addanimation:keyanimation Forkey:@"bbbb"]; - } the  - #pragmaMark-caanimationgroupWuyi-(Ibaction) Caanimationgroup: (ID) Sender { the     //Panning Animations -Cabasicanimation *basic1 =[cabasicanimation animation]; WuBasic1.keypath =@"TRANSFORM.TRANSLATION.Y";//Translate by y-axis -Basic1.tovalue = @ ( -); About     //Shrink Animation $Cabasicanimation *basic2 =[cabasicanimation animation]; -Basic2.keypath =@"Transform.scale";//Zoom Out -Basic2.tovalue = @ (0.3); -     //Rotate Animation ACabasicanimation *BASIC3 =[cabasicanimation animation]; +Basic3.keypath =@"transform.rotation";//Rotate theBasic3.tovalue =@ (M_PI); -      $     //you need to create animation groups that manage individual animations theCaanimationgroup *group =[Caanimationgroup animation]; theGroup.animations =@[basic1,basic2,basic3]; the     //Group will automatically allocate time theGroup.duration =5.0f; -      in[Self.imageView.layer addanimation:group Forkey:@"CCCCC"]; the } the  About #pragmaMark-caspring the-(Ibaction) Caspring: (ID) Sender { the     //Set Object theCaspringanimation *spring =[caspringanimation animation]; +Spring.keypath =@"Transform.scale"; -Spring.fromvalue = @1; theSpring.tovalue = @0.2;BayiSpring.duration =3.0f; the      the[Self.imageView.layer addanimation:spring Forkey:@"ddddd"]; - } -  the @end

Summarize:

Coreanimation (Calayer 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.