Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to decrease speed of rotating image with touch hold on UIView?

Hi I'm new to Iphone Development. I am creating a rotating image animation with variable speed. How ever I got variable speed but now i want to decrease speed with touch hold on UIView. I dont have any idea. So, can anybody help me? Can I get some code snippet for idea?

I have added some code snippet below

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

Thanks in advance

like image 997
jpd Avatar asked Mar 27 '26 08:03

jpd


1 Answers

i think you have trouble about detecting long time touch on UIView? try to customize these method of your own UIView

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

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

- (void) touchesEnded...

...etc

like image 115
Patrick.Ji Avatar answered Mar 29 '26 21:03

Patrick.Ji



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!