I am doing animation using the block level technique. I want to stop the animation based on a specific state. How can I stop the animation?
Below is my animation code:
[UIView animateWithDuration:2.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ if([arrAns count]>0) vwb1.center = CGPointMake(260, 40); } completion:^(BOOL finished){ [UIView animateWithDuration:1.5 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ if([arrAns count]>1) vwb2.center = CGPointMake(260, 100); } completion:^(BOOL finished){ [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ if([arrAns count]>2) vwb3.center = CGPointMake(260, 160); } completion:^(BOOL finished){ [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ if([arrAns count]>3) vwb4.center = CGPointMake(260, 220); } completion:^(BOOL finished){ [UIView animateWithDuration:1.0 delay:0.0 options:UIViewAnimationOptionAllowUserInteraction animations:^{ if([arrAns count]>4) vwb5.center = CGPointMake(260, 280); } completion:nil]; }]; }]; } ]; }];
I have no key here, so I cannot delete it based on the key. There is also a removeallanimation function, but I cannot use it. If someone can help me on how to use this, everything will be fine.
Edit: Ok, I figured out how to do this, I am doing this using the following code:
[self.view.layer removeAllAnimations]
But now I have a problem that my block level animation, which is not running yet, is still running. Therefore, if I delete the animation in the second block, it still executes the remaining block. I also need to stop this.
thanks
Pankai
source share