1
[UIView animateWithDuration:1 delay:4 options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseIn)
    animations:^
        {
            // do something here (irrelevant)
        }
        completion:nil
];

How do I stop the animation within the time of the delay? For example, I want to stop this animation after I execute it but before the delay timer ends. I've tried [self.view.layer removeAllAnimations]; but to no avail.

EDIT: As I've stated. I've tried [self.view.layer removeAllAnimations]; but to no avail.

wtoh
  • 200
  • 1
  • 7
  • Have you tried wrap it like this: `[CATransaction begin];[theView.layer removeAllAnimations];[CATransaction commit]`; – Jakub Truhlář Nov 19 '14 at 14:31
  • Can u please show the code inside the `animationWithDuration`. Maybe your `removeAllAnimations` is on another view and not on the view u want to cancel?! :/ – gran33 Nov 19 '14 at 15:04

2 Answers2

0

I didn't try it but you can stop all animations with [view.layer removeAllAnimations]; it should work.

Boran
  • 949
  • 10
  • 17
0

You could use NSTimer and then just call [timer invalidate] if you no longer want the animation to run.

E.g.:

NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval:4 target:self selector:@selector(animateView:) userInfo:nil repeats:NO];

// Then stop...

[timer invalidate];
Rob Sanders
  • 5,197
  • 3
  • 31
  • 58