Trying to figure out how to do a series of animations in Xcode
I don't want to give too much detail, but I am basically doing a开发者_C百科 series of animations. I'm moving a series of numbers from one side of the screen to the next, but I don't want them to move all at once. I'm trying to break up the animations via a for loop and several if loops within, but it doesn't work. I thought using the sleep() command would help, but it hasn't. How do you make animations run in a series instead of altogether?
Use the animateWithDuration:delay:options:animations:completion:
method on UIView
and set a delay time to stagger the animations. If you want to have them run one after another, you can have one animation start in the completion block of another:
[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
}
}];
You can find the documentation for all this in the UIView
class reference.
精彩评论