我怎样才能停止uiviewanimationoptionrecuiview动画?

时间:2021-03-09 20:23:18

I have the following code inside of a UIView subclass:

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

Then when I want to stop the Animation I send the following message to the View itself:

然后,当我想要停止动画时,我向视图本身发送以下消息:

[[self layer] removeAllAnimations];

But it does nothing... How can I stop the animation?

但它确实没有…我如何停止动画?

1 个解决方案

#1


4  

I fixed using the following piece of code:

我使用了以下代码:

- (void)restoreAnimations {

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

And calling it in the ViewController.

并在ViewController中调用它。

Btw. Thanks a lot Malloc!

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

#1


4  

I fixed using the following piece of code:

我使用了以下代码:

- (void)restoreAnimations {

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

And calling it in the ViewController.

并在ViewController中调用它。

Btw. Thanks a lot Malloc!

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