如何围绕另一个UIImage的界限动画UIImage

时间:2014-07-04 07:31:03

标签: ios objective-c uiimage core-animation image-rotation

我有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。

0 个答案:

没有答案