【发布时间】:2013-12-08 15:49:44
【问题描述】:
我在 UIView 子类中有以下代码:
[element setAlpha: 0.0f];
[UIView animateWithDuration: 0.4 delay: 0.0 options: UIViewAnimationOptionCurveEaseOut | UIViewAnimationOptionAutoreverse | UIViewAnimationOptionRepeat animations: ^{
[element setAlpha: 1.0f];
} completion: ^(BOOL finished){
if (finished)
{
return;
}
}];
然后,当我想停止动画时,我会向视图本身发送以下消息:
[[self layer] removeAllAnimations];
但它什么也没做...我怎样才能停止动画?
【问题讨论】:
-
别忘了:
#import <QuartzCore/QuartzCore.h> -
试试:
[self.layer removeAllAnimations];,还有,你有没有编译警告? -
不,可能是我调用[self.layer removeAllAnimations]的地方。我应该在视图内部还是在包含视图的 ViewController 中调用它?
-
你不应该在
element.layer上打电话给removeAllAnimations,而不是self.layer吗?
标签: ios iphone uiview ios7 uiviewanimation