2012-12-20 105 views
3

嗨,我是Iphone開發的新手。 我正在創建一個可變速度的旋轉圖像動畫。 我怎麼變速,但現在我想降低速度與觸摸按住UIView。 我沒有任何想法。那麼,有人能幫助我嗎?我可以得到一些想法的代碼片段嗎?如何降低UIView觸摸保持旋轉圖像的速度?

我已經加入下面

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]; 
    } 

由於一些代碼片斷提前

回答

1

我認爲你有關於UIView的檢測時間長觸摸麻煩嗎? 嘗試定製自己的UIView

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

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

- (void) touchesEnded... 

這些方法...等