有什么方法可以在 iOS 3 中停止动画?
我知道:
#import <QuartzCore/QuartzCore.h>
[view.layer removeAllAnimations];
, 但它仅适用于 iOS 4.0
有什么方法可以在 iOS 3 中停止动画?
我知道:
#import <QuartzCore/QuartzCore.h>
[view.layer removeAllAnimations];
, 但它仅适用于 iOS 4.0
试试这个代码:
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