Cakeyframeanimation
1 //cakeyframeanimation-Key pin animation2 @IBAction func cakfly ()3 {4Let animation = Cakeyframeanimation (keypath:"position")5 6 //Set 5 location points7Let P1 = Cgpointmake (0.0,0.0)8Let P2 = Cgpointmake ( the,0.0)9Let P3 = Cgpointmake (0,460.0)TenLet P4 = Cgpointmake (320.0,460.0) OneLet P5 = Cgpointmake (160.0,200.0) A - //Assign Value -Animation.values =[Nsvalue (CGPOINT:P1), Nsvalue (CGPOINT:P2), Nsvalue (CGPOINT:P3), Nsvalue (CGPOINT:P4), Nsvalue (CGPOINT:P5)] the - - //percentage of time per action -Animation.keytimes = [NSNumber (float:0.0), NSNumber (float:0.4), NSNumber (float:0.6), NSNumber (float:0.8), NSNumber (float:1.0)] + -Animation.Delegate= Self +Animation.duration =5.0 A atSelf.testImageView.layer.addAnimation (animation, Forkey:"Image-fly") - } - - //Animation Agent - OverrideFunc Animationdidstart (anim:caanimation!) - { in //Animation Start - } to + OverrideFunc Animationdidstop (anim:caanimation!, finished Flag:bool) - { the //End of animation *}
iOS development--Animation Programming Swift Chapter & (Fri) cakeyframeanimation