我有几个动画块,它们都遵循这个基本格式,但延迟不同,以便它们一个接一个地触发:
[UIView animateWithDuration:.85 delay:3 options:opts animations:[animations objectAtIndex:ww] completion:[completions objectAtIndex:ww]];
选项仅仅是为了方便访问将
UIViewAnimationOptionAutoreverse
放在一个变量中。我希望动画和完成之间有一定的延迟,这样图像就可以在返回原始位置之前保持新位置的状态。我考虑使用多个简单的
animateWithDuration:animations:
块,但是除非我遗漏了什么,否则我没有看到文档中如何使用延迟的方法。@Paul.s 这是我使用您给我的代码:
void (^completion)(void) = ^{
[UIView animateWithDuration:.5
delay:5
options:UIViewAnimationCurveLinear
animations:[completions objectAtIndex:ww]
completion:^(BOOL finished) {}];
};
// Call your existing animation with the new completion block
[UIView animateWithDuration:.5
delay:1
options:UIViewAnimationCurveLinear
animations:[animations objectAtIndex:ww]
completion:^(BOOL finished) {
completion();
}];
供参考,这个动画非常简单,只是将一张图片从一个点移动到另一个点,然后再返回。它崩溃的位置在定义完成块的[UIView animateWithDuration:.5
行,并且在第一部分动画运行后崩溃。
animations
之外,我发布的代码是来自一个正常工作的示例。 - Paul.s