让对象沿着某条路径移动的动画效果,摘自: 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;