我不想给出太多细节,但我基本上是在做一系列动画。我正在将一系列数字从屏幕的一侧移动到另一侧,但我不希望它们同时移动。我试图通过for循环和其中的几个if循环来分解动画,但这不起作用。我原以为使用sleep()命令会有所帮助,但事实并非如此。如何使动画在一个系列中运行,而不是完全运行?
在UIView
上使用animateWithDuration:delay:options:animations:completion:
方法,并设置延迟时间以错开动画。如果你想让它们一个接一个地运行,你可以在另一个的完成块中开始一个动画:
[UIView animateWithDuration:0.5 animations:^
{
//Do your first round of animations here
} completion: ^(BOOL completed)
{
//Start the next round
[UIView animateWithDuration:0.5 animations:^
{
//second round of animations
//Nest this structure as deep as needed
}
}];
您可以在UIView
类参考中找到所有这些的文档。