0

I have 2 Images. 1 Outer Image and 1 Inner Image. I am trying to get the outer Image to rotate around the bounds of the inner Image. I am kind of close with the code I have (shown below) but I can't get the outer Image to perfectly rotate around the Inner Image.

CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];

    pathAnimation.calculationMode = kCAAnimationPaced;

    pathAnimation.fillMode = kCAFillModeForwards;
    pathAnimation.removedOnCompletion = NO;
    pathAnimation.duration = 5.0;


    pathAnimation.repeatCount = 10;


    CGMutablePathRef curvedPath = CGPathCreateMutable();
    CGPathMoveToPoint(curvedPath, NULL, 10, 10);


    CGRect rectangle = CGRectMake(self.view.frame.origin.x/2,self.view.frame.origin.y/2,200,200);

    CGPathAddEllipseInRect(curvedPath, NULL, rectangle);


    pathAnimation.path = curvedPath;
    CGPathRelease(curvedPath);



    [self.head.layer addAnimation:pathAnimation forKey:@"moveTheObject"];

Thanks for your help

EDIT** The inner Image is Circle around 180 x 180 px and the outer Image is a square. around 50 x 50 px.

user2632573
  • 105
  • 1
  • 8
  • why can't you simply align the center of the images and then rotate the outer one? (might be missing the point) – Mika Jul 04 '14 at 07:49
  • The inner Image is Circle around 180 x 180 px and the outer Image is a square. around 50 x 50 px. so that wont work – user2632573 Jul 04 '14 at 08:02
  • 2
    Oh! they are not superimposed it's turning around it! Why don't you add 180/2px of transparent space to the side of the outer image and just rotate. – Mika Jul 04 '14 at 08:14

0 Answers0