0

I set animation effect after do panning object

-(void)panView:(UIPanGestureRecognizer*)recognizer{
    //do sth...

    if(recogizer.state==UIGestureRecognizerStateEnded){
        [UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionCurveEaseOut animation^{
            //do sth2...
        }completion:^(BOOL finished){
            //do sth3...
        }];
    }

}

The problem is while animation is playing and I pan that object again. The new panning is not happen and I should wait until animation complete so I can do panning again.

How can I interrupt animation to suddenly do new panning???

Solution

add UIViewAnimationOptionAllowUserInteraction to options. and may set self.layer removeAllAnimations before redo pan.

user1047504
  • 578
  • 7
  • 14

1 Answers1

0

Try following code

-(void)panView:(UIPanGestureRecognizer*)recognizer
{

    //do sth...

    [animatingView.layer removeAllAnimations];

    if(recogizer.state==UIGestureRecognizerStateEnded)
    {
        [UIView animateWithDuration:1 delay:0 options:UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionAllowUserInteraction animation^{

            //do sth2...

        }completion:^(BOOL finished){

            //do sth3...

        }];
    }

}
Nirav Gadhiya
  • 6,342
  • 2
  • 37
  • 76