Cancel a UIView animation?

Posted by Phil Nash on Stack Overflow See other posts from Stack Overflow or by Phil Nash
Published on 2009-02-16T23:19:41Z Indexed on 2010/03/23 21:53 UTC
Read the original article Hit count: 276

Is it possible to cancel a UIView animation while it is in progress? Or would I have to drop to the CA level?

i.e. I've done something like this (maybe setting an end animation action too):

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve: UIViewAnimationCurveLinear];
// other animation properties

// set view properties

[UIView commitAnimations];

But before the animation completes and I get the animation ended event, I want to cancel it (cut it short). Is this possible? Googling around finds a few people asking the same question with no answers - and one or two people speculating that it can't be done.

© Stack Overflow or respective owner

Related posts about cocoa-touch

Related posts about core-animation