B.S.
B.S.

Reputation: 21726

How to stop UIView animation in iOS < 4

Is there any way to stop animation in iOS 3 ?

I know about:

 #import <QuartzCore/QuartzCore.h>
 [view.layer removeAllAnimations];   

, but it works only in iOS 4.0

Upvotes: 0

Views: 730

Answers (1)

graver
graver

Reputation: 15213

Try with this code:

if([view.layer repondsToSelector:@selector(removeAllAnimations)]) //Check if the CALayer responds to removeAllAnimations method for iOS4+
    [view.layer removeAllAnimations];
else
    [view.layer addAnimation:nil forKey:@"TheKeyOfTheAnimation"]; // Change TheKeyOfTheAnimation with key you have added animation for, you can also use nil for the key...

UPDATE: According to the docs removeAllAnimations is available since iOS2.0 removeAllAnimations Remove all animations attached to the receiver.

- (void)removeAllAnimations
Availability
Available in iOS 2.0 and later.
Declared In
CALayer.h

Upvotes: 1

Related Questions