Core Animation -06-Key-frame animation-day4

Source: Internet
Author: User

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

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.