0

有什么方法可以在 iOS 3 中停止动画?

我知道:

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

, 但它仅适用于 iOS 4.0

4

1 回答 1

1

试试这个代码:

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...

更新:根据文档 removeAllAnimations 自 iOS2.0 起可用 removeAllAnimations 删除附加到接收器的所有动画。

- (void)removeAllAnimations
Availability
Available in iOS 2.0 and later.
Declared In
CALayer.h
于 2012-07-05T07:41:44.120 回答