我无法使用触摸为轮子设置动画。我花了一些时间为持续时间、旋转时间和动画持续时间输入不同的数字值,以使用 thouchsMove 获得平滑移动,但每次触摸发生时,轮子都会旋转,似乎正在发生的事情是它跳回原来的位置。如果有人能对此有所了解,我将不胜感激。
CABasicAnimation* rotationAnimation;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.fillMode = kCAFillModeForwards;
rotationAnimation.removedOnCompletion = NO;
rotationAnimation.delegate = self;
rotationAnimation.toValue = [NSNumber numberWithFloat: 2 * 1 * 45 ];
rotationAnimation.duration = 2;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = 1;
rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[animatedImage.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];