Posted By

sag333ar on 03/01/11


Tagged

xcode Objective-c iphone iOS4 CABasicAnimation CAKeyframeAnimation CGPath CAAnimationGroup iOS42 3GS 3G 2G


Versions (?)

Who likes this?

4 people have marked this snippet as a favorite

sag333ar
athanhcong
Tintenklecks
cnathan


CABasicAnimation - animation on path


 / Published in: Objective C
 

  1. CAKeyframeAnimation *bounceAnimation=[CAKeyframeAnimation animationWithKeyPath:@"position"];
  2. bounceAnimation.duration=timeForAnimation;
  3.  
  4. CGMutablePathRef thePath=CGPathCreateMutable();
  5.  
  6. CGPathMoveToPoint(thePath, NULL, 160, 514);
  7.  
  8. CGPathAddLineToPoint(thePath, NULL, 160, 350);
  9. CGPathAddLineToPoint(thePath, NULL, 160, 406);
  10. bounceAnimation.path=thePath;
  11. CGPathRelease(thePath);
  12.  
  13. CABasicAnimation *mainAnimation=[CABasicAnimation animationWithKeyPath:@"transform"];
  14. mainAnimation.removedOnCompletion=YES;
  15. mainAnimation.duration=timeForAnimation;
  16. mainAnimation.toValue=[NSValue valueWithCATransform3D:CATransform3DIdentity];
  17.  
  18.  
  19. CAAnimationGroup *theGroup=[CAAnimationGroup animation];
  20. theGroup.delegate=self;
  21. theGroup.duration=timeForAnimation;
  22. theGroup.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
  23. theGroup.animations=[NSArray arrayWithObjects:bounceAnimation,mainAnimation,nil];
  24. [imgV.layer addAnimation:theGroup forKey:@"sagar"];
  25. imgV.center=CGPointMake(160, 406);
  26. imgV.transform=CGAffineTransformIdentity;

Report this snippet  

You need to login to post a comment.