我需要将对象(UIImageView)从A点移动到B点,然后将B点处的图像旋转180度以面对相反的方向并将对象从B移动到A(向后)。使用CAKeyframeAnimation处理动画期间处理UIImageView
我有下面的代码从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];
我其实有一条复杂的路径可以穿行。为了简单起见,我使用A和B. YOu提到CGAnimation,但我没有初始化该对象。我会研究如何去做。谢谢 – Vad
@Vad:我的意思是CAAnimation,它是CAKeyframeAnimation的超类。苹果为他们的课程设置了许多不同的小前缀。 – Anomie