我需要爲UIImageView從起點到終點添加無限動畫,然後從終點到起點添加無限動畫。 我想是這樣的:從起點CAKeyframeAnimation從頭到尾重複動畫
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeForwards;
pathAnimation.removedOnCompletion = NO;
pathAnimation.duration = 2.0;
pathAnimation.repeatCount = HUGE_VALF;
pathAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
CGPoint endPoint = CGPointMake(320.0f - 30.0f, self.myImage.frame.size.height);
CGMutablePathRef curvedPath = CGPathCreateMutable();
CGPathMoveToPoint(curvedPath, NULL, self.myImage.frame.origin.x, self.myImage.frame.origin.y);
CGPathAddCurveToPoint(curvedPath, NULL, endPoint.x, self.myImage.frame.origin.y,
endPoint.x, self.myImage.frame.origin.y, endPoint.x, endPoint.y);
pathAnimation.path = curvedPath;
CGPathRelease(curvedPath);
[self.myImage.layer addAnimation:pathAnimation forKey:@"curveAnimation"];
MYIMAGE移動到結束好了,但在那之後移動到起點和從起點重複動畫結束。所以,從結束點開始沒有動畫。有可能嗎?