gpt4 book ai didi

iOS:重复动画 block 直到事件完成

转载 作者:行者123 更新时间:2023-11-29 12:09:39 25 4
gpt4 key购买 nike

我有以下动画 block ,它旋转一个按钮一次。我想继续旋转按钮,直到 refreshPendingRequests 方法完成。

refreshPendingRequests 方法从我的服务器检索数据,因此我想继续旋转按钮直到检索到数据。

CGFloat direction = 1.0f;  // -1.0f to rotate other way
refreshButton.transform = CGAffineTransformIdentity;
[UIView animateKeyframesWithDuration:1.0 delay:0.0
options:UIViewKeyframeAnimationOptionCalculationModePaced | UIViewAnimationOptionCurveEaseInOut
animations:^{
[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.0 animations:^{
refreshButton.transform = CGAffineTransformMakeRotation(M_PI * 2.0f / 3.0f * direction);
}];
[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.0 animations:^{
refreshButton.transform = CGAffineTransformMakeRotation(M_PI * 4.0f / 3.0f * direction);
}];
[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.0 animations:^{
refreshButton.transform = CGAffineTransformIdentity;
}];
}
completion:^(BOOL finished) {
[self performSelector:@selector(refreshPendingRequests) withObject:nil afterDelay:0.0];
}];

有谁知道我是否可以调用某种类型的repeats 属性,或者我如何执行此动画直到refreshPendingRequests 事件完成?

最佳答案

确实有一个选项:UIViewKeyframeAnimationOptionRepeat

传递该选项,并为您的完成 block 传递 nil,因为您不需要它。

[UIView animateKeyframesWithDuration:1.0 delay:0.0
options:UIViewKeyframeAnimationOptionCalculationModePaced | UIViewAnimationOptionCurveEaseInOut | UIViewKeyframeAnimationOptionRepeat
animations:^{
[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.0 animations:^{
refreshButton.transform = CGAffineTransformMakeRotation(M_PI * 2.0f / 3.0f * direction);
}];
[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.0 animations:^{
refreshButton.transform = CGAffineTransformMakeRotation(M_PI * 4.0f / 3.0f * direction);
}];
[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.0 animations:^{
refreshButton.transform = CGAffineTransformIdentity;
}];
}
completion:nil];

然后当你的刷新完成时:

[refreshButton.layer removeAllAnimations];

关于iOS:重复动画 block 直到事件完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33878412/

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