0

我无法使用触摸为轮子设置动画。我花了一些时间为持续时间、旋转时间和动画持续时间输入不同的数字值,以使用 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"];
4

2 回答 2

0

对于那些感兴趣的代码,下面是获得预期效果所需要的

CGAffineTransform transforms = CGAffineTransformConcat(animatedImage.transform,CGAffineTransformMakeRotation(M_PI/2));
animatedImage.transform = transforms;
于 2011-06-21T00:23:09.200 回答
0

如果您遇到同样的问题,请按照此示例进行操作,它的位置。 http://ericmcconkie.com/2010/03/trig-and-objective-c/

于 2011-07-22T13:56:56.707 回答