Key-Frame animations for iOS core animations

Source: Internet
Author: User

1 #import "NJViewController.h"2 3 @interfaceNjviewcontroller ()4 5@property (Weak, nonatomic) Iboutlet UIView *CustomView;6-(Ibaction) Btnclick: (ID) sender;7 @end8 9 @implementationNjviewcontrollerTen  One- (void) Touchesbegan: (Nsset *) touches withevent: (Uievent *)Event A { -  - [self test1]; the //[self test1]; - } -  -- (void) Test1 + { -     //1. Create a core animation +Cakeyframeanimation *keyanima =[cakeyframeanimation animation]; A     //1.1 Tell the system what animations to perform atKeyanima.keypath =@"position"; -      -Cgmutablepathref Path =cgpathcreatemutable (); -Cgpathaddellipseinrect (Path, NULL, CGRectMake (0, -, $, $)); -      -Keyanima.path =path; in cgpathrelease (path); -      to     //1.2 Save status after execution +     //1.2.1 Do not delete animations after execution finishes -Keyanima.removedoncompletion =NO; the     //Save up-to-date status after 1.2.2 execution *Keyanima.fillmode =kcafillmodeforwards; $     Panax Notoginseng     //1.3 Setting Animation time -Keyanima.duration =2; the     //2. Watch when the animation starts and when it's done +Keyanima.Delegate=Self ; A     //3. Add a core animation the[Self.customView.layer Addanimation:keyanima Forkey:@"ABC"]; + } -  $-(Ibaction) Btnclick: (ID) Sender { $      -     //Stop Animation -[Self.customView.layer Removeanimationforkey:@"ABC"]; the } - Wuyi  the- (void) Test - { Wu     //1. Create a core animation -Cakeyframeanimation *keyanima =[cakeyframeanimation animation]; About     //1.1 Tell the system what animations to perform $Keyanima.keypath =@"position"; -     //nsvalue *v1 = [Nsvalue valuewithcgpoint:cgpointmake (0)]; -Nsvalue *v2 = [Nsvalue valuewithcgpoint:cgpointmake ( -, -)]; -Nsvalue *v3 = [Nsvalue valuewithcgpoint:cgpointmake ( -, $)]; ANsvalue *v4 = [Nsvalue valuewithcgpoint:cgpointmake (0, $)]; +Nsvalue *v5 = [Nsvalue valuewithcgpoint:cgpointmake (0, -)]; the      -Keyanima.values =@[v2, v3, V4, V5]; $      the     //keyanima.keytimes = @[@ (0.5), @ (0.5), @ (0.5)]; the      theKeyanima.timingfunction =[Camediatimingfunction functionwithname:kcamediatimingfunctioneaseineaseout]; the      -     //1.2 Save status after execution in     //1.2.1 Do not delete animations after execution finishes theKeyanima.removedoncompletion =NO; the     //Save up-to-date status after 1.2.2 execution AboutKeyanima.fillmode =kcafillmodeforwards; the      the     //1.3 Setting Animation time theKeyanima.duration =2; +      -     //2. Watch when the animation starts and when it's done theKeyanima.Delegate=Self ;Bayi      the      the     //2. Add a core animation - [Self.customView.layer Addanimation:keyanima forkey:nil]; - } the  the- (void) Animationdidstart: (Caanimation *) Anim the { theNSLog (@"Animationdidstart"); - } the  the- (void) Animationdidstop: (Caanimation *) Anim finished: (BOOL) Flag the {94NSLog (@"Animationdidstop"); the } the  the 98 @end

Key-Frame animations for iOS core animations

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.