【问题标题】:How to decrease speed of rotating image with touch hold on UIView?如何通过触摸 UIView 来降低旋转图像的速度?
【发布时间】:2012-12-20 13:23:19
【问题描述】:

您好,我是 Iphone Development 的新手。 我正在创建一个可变速度的旋转图像动画。 我是如何获得变速的,但现在我想通过按住UIView 来降低速度。 我没有任何想法。那么,有人可以帮助我吗?我可以得到一些代码 sn-p 吗?

我在下面添加了一些代码sn-p

CABasicAnimation* rotationAnimation;

    rotationAnimation =
    [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.fromValue = [NSNumber numberWithFloat: M_PI *2.0 * appDelegate.direction];
    rotationAnimation.repeatCount = 1;
    rotationAnimation.duration = interval;
    rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
    rotationAnimation.fillMode = kCAFillModeForwards;
    rotationAnimation.removedOnCompletion = YES;
    [imgv.layer addAnimation:rotationAnimation forKey:@"rotation"];

    if(count<=repeatcount)
    {
        [self performSelector:@selector(funTime) withObject:nil afterDelay:interval];
        isNotRotating = TRUE;
        interval = interval + addTime;
        addTime = addTime+0.001;
        lblCount.text = [NSString stringWithFormat:@"%d",count];
        count++;
        NSLog(@"duration to rotate a single rotation %f",(interval+((repeat-1) *0.10)/repeat));
    }
    else
    {
        tap=0;
        isNotRotating= TRUE;
        [imgv.layer removeAllAnimations];
    }

提前致谢

【问题讨论】:

    标签: objective-c ios cocoa-touch cabasicanimation


    【解决方案1】:

    我认为您在检测 UIView 上的长时间触摸时遇到了麻烦? 尝试自定义你自己的 UIView 的这些方法

    - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
    
    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    
    - (void) touchesEnded...
    

    ...等

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-24
      相关资源
      最近更新 更多