gpt4 book ai didi

ios - 如何停止 UIViewAnimationOptionRepeat UIView 动画?

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:47:08 27 4
gpt4 key购买 nike

我在 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];

但它什么也没做...我怎样才能停止动画?

最佳答案

我使用以下代码修复:

- (void)restoreAnimations {

[UIView animateWithDuration:0.1 delay:0.0 options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveLinear animations:^{
[element setAlpha: 1.0f];
} completion:NULL];
}

并在 ViewController 中调用它。

顺便说一句。非常感谢 Malloc!

关于ios - 如何停止 UIViewAnimationOptionRepeat UIView 动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20455357/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com