0
votes

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:

2
Are you trying to rotate the image as it moves along the arc?William Jockusch
Yes, that is exactly what I am trying to do.Oh Danny Boy

2 Answers

2
votes

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"];
1
votes

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.