views:

42

answers:

2

I understand that CGAffineTransformMakeRotation can rotate an image, and CGAffineTransformMakeTranslation translates an image. I also understand CGAffineTransformConcat can merge two transformations. However, I cannot seem to figure out a way to move an image on an arc using both of these. I understand this is more a mathematical question but does anyone have a reference they can point me to?

Edit:

 [bezierPathWithArcCenter:radius:startAngle:endAngle:clockwise:]

did the trick.

Reference: http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIBezierPath_class/Reference/Reference.html#//apple_ref/occ/clm/UIBezierPath/bezierPathWithArcCenter:radius:startAngle:endAngle:clockwise:

+1  A: 

Rotate it about the center of the circle corresponding to the arc.

This will involve three steps:

1) Translate so that the center of your arc moves to the origin.
2) Rotate through the appropriate angle.
3) Reverse the translation from step 1.

William Jockusch
+1  A: 

Use a CAKeyframeAnimation with the path set instead of discreet values.

CAKeyframeAnimation *a = [CAKeyframeAnimation animationWithKeyPath:@"position"];
CGRect circleRect = CGRectMake(0,0,50,50);
a.duration = 2.0;
a.rotationMode = kCAAnimationRotateAuto;
a.path = [UIBezierPath bezierPathWithOvalInRect:circleRect].CGPath;
[imageView.layer addAnimation:a forKey:@"moveCircle"];
Jason Harwig