Reputation: 5936
I have two objects that fade into display simultaneously that are initially set to hidden
, I want to fire the second animation a couple of seconds after the first but they both fade in at the same time?
_text.alpha = 0;
_text.hidden = NO;
[UIView animateWithDuration:1.9 animations:^{
_text.alpha = 1;
}];
////////////second animation
_note.alpha = 0;
_note.hidden = NO;
[UIView setAnimationDelay:2.0];
[UIView animateWithDuration:1.9 animations:^{
_note.alpha = 1;
}];
Upvotes: 1
Views: 2183
Reputation: 9251
Try this:
[UIView animateWithDuration:1.9 animations:^{
_text.alpha = 1;
} completion:^(BOOL finished) {
[UIView animateWithDuration:1.9 animations:^{
_note.alpha = 1;
}];
}];
The second block gets called when the first animation ended.
Upvotes: 4
Reputation: 901
Use the animateWithDuration:animations:completion:
method as described in the apple docs. Put the second animation into the completion block of the first one.
Upvotes: 2