我有2张图片。 1个外部图像和1个内部图像。我试图让外部图像围绕内部图像的边界旋转。我对我的代码很接近(如下所示),但我不能让外部图像完全围绕内部图像旋转。
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"];
感谢您的帮助
编辑**内部图像是圆周围180 x 180像素,外部图像是正方形。约50 x 50 px。