IOS Core Animation

Source: Internet
Author: User

Core Animation

basic 3 kinds of animations: basic animation cabasicanimation, keyframe animation cakeyframeanimation, transition animation catransition

and then there's the animation group: Caanimationgroup

First, the use of basic animation cabasicanimation:

Cabasicanimation * Animation =[cabasicanimation animation]; //the values of the corresponding properties are as follows: Transform.scale (scale), transform.rotation.z (Z axis, when rotating) ... Animation.keypath =KeyPath; Animation.tovalue= Tovalue;//If you change the value at the end of the zoom Tovalue = @0.5, rotation angle Tovalue = @ (M_PI)Animation.repeatcount =maxfloat; //do not remove the animation when you set the animation to completeAnimation.removedoncompletion =NO; //set the animation execution to stay up to date with the effectAnimation.fillmode =kcafillmodeforwards; /*Duration animation Duration RepeatCount Animation cycle RepeatDuration Animation time timingfunction animation speed Change Fromvalue Change the starting value of the property tovalue the value at the end of the changed property*/
Add to the layer of the corresponding view
[View.layer addanimation:animation Forkey:nil];

Second, key frame animation cakeyframeanimation

1. Simulate an iOS system to remove animations that apply shaking

Cakeyframeanimation * rotation = [cakeyframeanimation animation];     // corresponding Property    @" transform.rotation " ;     // Each keyframe changes the value    of the property Rotation.values = @[@ (toradion (-5)), @ (Toradion (5)), @ (Toradion (-5))];     = maxfloat;    // add to the layer on    the corresponding view [View.layer addanimation:rotation Forkey:nil];

2. Motion Trajectory

//create a path or get a pathUibezierpath * Bezierpath =[Uibezierpath Bezierpath]; [Bezierpath Movetopoint:cgpointmake (0, -)]; [Bezierpath Addlinetopoint:cgpointmake ( -, -)]; [Bezierpath Addlinetopoint:cgpointmake ( -, -)]; [Bezierpath Addlinetopoint:cgpointmake ( $, -)]; [Bezierpath Addlinetopoint:cgpointmake ( -, -)]; [Bezierpath Addlinetopoint:cgpointmake ( -, -)]; [Bezierpath Addlinetopoint:cgpointmake ( the, -)]; [Bezierpath Addlinetopoint:cgpointmake (380, -)]; [Bezierpath Addlinetopoint:cgpointmake ( the, -)]; Cakeyframeanimation* Position =[cakeyframeanimation animation]; Position.keypath=@"position"; //Animation Move PathPosition.path =Bezierpath.cgpath; Position.repeatcount=maxfloat; Position.duration=3; //add to the layer on the corresponding view[View.layer addanimation:rotation Forkey:nil];

Third, transition animation catransition

Transition animation must be used when the transition is valid, such as: Change the picture of Uiimageview

//when changing the Imageview.image (transitions)_imageview.image =[UIImage imagenamed:img]; Catransition*atransition =[catransition animation]; //typeAtransition.type =@"Rippleeffect"; Atransition.duration=1;
   //Add to layer on _imageview [_imageview.layer addanimation:atransition Forkey:nil]; /*type 1. #define定义的常量 kcatransitionfade crossfade Transition kcatransitionmovein New view moves to the old view Kcatransitionpush The new view launches the old view kcatransitionreveal the old view away, showing the new view below 2. String representation pagecurl up one page Pageuncurl Turn down one page rippleeffect drip effect suckeffect shrinkage effect, such as a piece of cloth was pumped away cube cube effect Oglflip Top and bottom Rollover effect*/

Four, animation group Caanimationgroup

This is very simple, just put a few animations in an array to perform the animation

//Zoom, pan, rotate at the same time//Create a group of animationsCaanimationgroup *group =[Caanimationgroup animation]; //ZoomCabasicanimation *scale =[cabasicanimation animation]; Scale.keypath=@"Transform.scale"; Scale.tovalue= @0.5; //RotateCabasicanimation *rotation =[cabasicanimation animation]; Rotation.keypath=@"transform.rotation"; Rotation.tovalue=@ (Arc4random_uniform (M_PI)); //panningCabasicanimation *position =[cabasicanimation animation]; Position.keypath=@"position"; Position.tovalue= [Nsvalue valuewithcgpoint:cgpointmake (Arc4random_uniform ( $), Arc4random_uniform ( $))]; //Add to Animation groupGroup.animations =@[scale,rotation,position]; //add to the layer on the corresponding view[View.layer Addanimation:group Forkey:nil];

Simple introduction not good not to spray.

IOS Core 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.