1 //2 //VIEWCONTROLLER.M3 //06 Keyframe 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 { - cgmutablepathref _path; - } the@property (Weak, nonatomic) Iboutlet UIView *Redview; - - @end - + @implementationViewcontroller - +- (void) Viewdidload { A [Super Viewdidload]; at -_redview.layer.cornerradius =Ten; - - - - } in - to- (void) Touchesbegan: (Nsset<uitouch *> *) touches withevent: (Uievent *)Event { + - //Key-Frame animations the //cakeyframeanimation *keyframe = [cakeyframeanimation animationwithkeypath:@ "position"]; * // $ // //Create framePanax Notoginseng //Cgpoint point1 = cgpointmake (+); - //Cgpoint Point2 = Cgpointmake (n.); the //Cgpoint Point3 = cgpointmake (+); + //Cgpoint point4 = Cgpointmake (); A //Cgpoint point5 = Cgpointmake (n.); the //Cgpoint point6 = cgpointmake (+); + // - // $ //Nsarray *array = @[[nsvalue Valuewithcgpoint:point1], $ //[Nsvalue Valuewithcgpoint:point2], - //[Nsvalue Valuewithcgpoint:point3], - //[Nsvalue valuewithcgpoint:point4], the //[Nsvalue valuewithcgpoint:point5], - //[Nsvalue Valuewithcgpoint:point6]Wuyi // ]; the // - //keyframe.values = array; Wu // - //keyframe.duration = 3; About // $ // //add an animation to a layer - //[_redview.layer addanimation:keyframe forkey:@ "Keyframe"]; - - A + the if(_path) { - cgpathrelease (_path); $_path =NULL; the } the the //Create Path the_path =cgpathcreatemutable (); - //set Path start point inUitouch *touch =[touches anyobject]; theCgpoint location =[Touch LocationInView:self.view]; the Cgpathmovetopoint (_path, NULL, location.x, LOCATION.Y); About the } the the- (void) touchesmoved: (Nsset<uitouch *> *) touches withevent: (Uievent *)Event { + //Get Touch Point add path point -Uitouch *touch =[touches anyobject]; theCgpoint location =[Touch LocationInView:self.view];Bayi the Cgpathaddlinetopoint (_path, NULL, location.x, LOCATION.Y); the - } - the- (void) touchesended: (Nsset<uitouch *> *) touches withevent: (Uievent *)Event { the the //Performing animations theCakeyframeanimation *keyframe = [cakeyframeanimation animationwithkeypath:@"position"]; -Keyframe.path =_path; the the theKeyframe.duration =5;94 the the the //speed control function98Keyframe.timingfunction =[Camediatimingfunction functionwithname:kcamediatimingfunctioneaseineaseout]; About - 101 [_redview.layer addanimation:keyframe forkey:nil];102 103 }104 the 106 107- (void) didreceivememorywarning {108 [Super didreceivememorywarning];109 //Dispose of any resources the can be recreated. the }111 the @end
Core Animation -06-Key-frame animation-day4