【发布时间】:2011-07-22 21:56:56
【问题描述】:
我无法使用触摸为轮子设置动画。我花了一些时间为持续时间、旋转时间和动画持续时间输入不同的数字值,以使用 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"];
【问题讨论】:
-
我无法重现重置。您能否告诉我们是否有与
animatedImage相关的手势识别器或触摸处理? -
嗨,我不确定我是否理解,我正在从 - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 调用上述方法
-
所以你在触摸时开始这个动画,然后在动画结束后,它会回到原来的位置吗?
-
不完全是,动画在您保持联系时被调用。例如,想象一个音乐转盘,您正在用手指上下移动 LP。我想通过在不抬起手指的情况下以圆周运动移动我的 uiimageview 来创建相同的效果
标签: objective-c ipad cabasicanimation