我需要为 UIImageView 从起点到终点添加无限动画,然后从终点到起点。我正在尝试这样:
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 从起点移动到终点可以,但之后移动到起点并从起点到终点重复动画。所以,从终点到起点没有动画。有可能吗?