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

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-29
  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-09
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
  • 2021-04-07
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案