我在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;
}
}];
然后当我想停止动画时,我将以下消息发送给View本身:
[[self layer] removeAllAnimations];
但它什么都不做......我怎么能停止动画?
答案 0 :(得分:4)
我使用以下代码修复:
- (void)restoreAnimations {
[UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveLinear animations:^{
[element setAlpha: 1.0f];
} completion:NULL];
}
在ViewController中调用它。
顺便说一下。非常感谢Malloc!