0

I thought I was used to completion handlers but for some reason I think I have implemented this wrong.

The animation breaks if I tap the 'button' in quick succession. By breaks I mean seems to increase the X position.

I am looking for the animation to not be affected by the touch until its complete

 if(self.segmentedView.selectedSegmentIndex == 0 && !animating){

        //NORMAL CODE IS HERE

        POPSpringAnimation *layerPositionAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionX];
        animating = YES;
        layerPositionAnimation.toValue = @(self.triangle.layer.position.x - secondSegmentWidth);
        layerPositionAnimation.springBounciness = 10;
        layerPositionAnimation.springSpeed = 20;
        [layerPositionAnimation setCompletionBlock:^(POPAnimation *animation, BOOL finished) {
            animating = NO;

        }];
        [self.triangle.layer pop_addAnimation:layerPositionAnimation forKey:@"layerPositionAnimation"];

    } 
Allreadyhome
  • 1,252
  • 2
  • 25
  • 46

0 Answers0