【Objecitve C代码】让对象沿着某条路径移动的动画效果
让对象沿着某条路径移动的动画效果,摘自: http://snipplr.com/view.php?codeview&id=49869
CAKeyframeAnimation *bounceAnimation=[CAKeyframeAnimation animationWithKeyPath:@"position"];
bounceAnimation.duration=timeForAnimation;
CGMutablePathRef thePath=CGPathCreateMutable();
CGPathMoveToPoint(thePath, NULL, 160, 514);
CGPathAddLineToPoint(thePath, NULL, 160, 350);
CGPathAddLineToPoint(thePath, NULL, 160, 406);
bounceAnimation.path=thePath;
CGPathRelease(thePath);
CABasicAnimation *mainAnimation=[CABasicAnimation animationWithKeyPath:@"transform"];
mainAnimation.removedOnCompletion=YES;
mainAnimation.duration=timeForAnimation;
mainAnimation.toValue=[NSValue valueWithCATransform3D:CATransform3DIdentity];
CAAnimationGroup *theGroup=[CAAnimationGroup animation];
theGroup.delegate=self;
theGroup.duration=timeForAnimation;
theGroup.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
theGroup.animations=[NSArray arrayWithObjects:bounceAnimation,mainAnimation,nil];
[imgV.layer addAnimation:theGroup forKey:@"sagar"];
imgV.center=CGPointMake(160, 406);
imgV.transform=CGAffineTransformIdentity;
----==== Email: slofslb (GTD) qq.com 请将(GTD)换成@ ====----
版权声明:自由转载-非商用-非衍生-保持署名(创意共享3.0许可证)
作者:申龙斌的程序人生
---- 魔方、桥牌、象棋、游戏人生...
---- BASIC、C++、JAVA、C#、Haskell、Objective-C、Open Inventor、程序人生...
---- GTD伴我实现人生目标
---- 区块链生存训练
---- 用欧拉计划学Rust编程
---- 申龙斌的读书笔记(2011-2019)
----