我需要将对象(UIImageView)从 A 点移动到 B 点,然后将 B 点处的图像旋转 180 度以面向相反方向并将对象从 B 移动到 A(向后)。
我有下面的代码,它从 A 移动到 B。我也知道如何旋转 UIImageView。但是如何知道对象何时到达 B 点以及考虑到屏幕上有很多对象如何应用旋转动作?
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
pathAnimation.duration = speed;
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeForwards;
pathAnimation.removedOnCompletion = NO;
CGMutablePathRef pointPath = CGPathCreateMutable();
CGPathMoveToPoint(pointPath, NULL, rect.origin.x, rect.origin.y);
CGPathAddLineToPoint(pointPath, NULL, x, y);
pathAnimation.path = pointPath;
CGPathRelease(pointPath);
[imageView.layer addAnimation:pathAnimation forKey:[NSString stringWithFormat:@"pathAnimation%@",objId]];
[imageView release];