1 //2 //VIEWCONTROLLER.M3 //05 Basic Animations4 //5 //Created by Zhujiacong on 16/4/18.6 //copyright©2016 year WXHL. All rights reserved.7 //8 9 #import "ViewController.h"Ten One @interfaceViewcontroller () A@property (Weak, nonatomic) Iboutlet Uiimageview *ImageView; - - @end the - @implementationViewcontroller - - + --(Ibaction) Start: (ID) Sender { + A //1 initializing animated objects at //KeyPath The value that needs to be changed during the animation -Cabasicanimation *basicanimation = [cabasicanimation animationwithkeypath:@"position"]; - //2 Setting the value of the property change -Basicanimation.fromvalue = [Nsvalue valuewithcgpoint:cgpointmake ( Max,0)]; -Basicanimation.tovalue = [Nsvalue valuewithcgpoint:cgpointmake ( Max, -)]; - in //Animation Duration -Basicanimation.duration =3; to + //automatic playback of animations - //after the animation is finished, back to the automatic reverse animation, return the animation start State the //single play time unchanged, the total time is twice times the original *Basicanimation.autoreverses =NO; $ Panax Notoginseng //cycle times do not change the duration of each animation -Basicanimation.repeatcount =5; the //set the start time of the animation + //basicanimation.begintime = cacurrentmediatime () + 3; A //fill mode for animations the /* + Kcafillmodeforwards after the animation finishes playing, leave the layer until the end - kcafillmodebackwards the layer remains in the start position before the animation starts $ Kcafillmodeboth The set of the two above $ kcafillmoderemoved When the animation is finished, the animation effect is removed and the layer returns to its original state - */ -Basicanimation.removedoncompletion =NO; the -Basicanimation.fillmode =Kcafillmodeboth;Wuyi the - //playback speed does not affect the waiting time Wu //basicanimation.speed = 2.0; - //offset of Time AboutBasicanimation.timeoffset =1.5; $ - - //add an animation to a layer -[_imageview.layer addanimation:basicanimation Forkey:@"Basic"]; A + } the -- (void) Viewdidload { $ [Super Viewdidload]; the //additional setup after loading the view, typically from a nib. the } the the- (void) didreceivememorywarning { - [Super didreceivememorywarning]; in //Dispose of any resources the can be recreated. the } the About @end
Core Animation -05-Basic animation-day4