AFAIU, the inner animation takes control over the duration which is mentioned in the outer animation block. Whereas, function inside the completion block does not seem to wait until the main animation block finishes its animation task with the given time duration.
So, lets say DURATION_X is 5 seconds, DURATION_Y is 20 seconds and DURATION_Z is 10 seconds respectively. What happens is that the animation function inside the completion block gets triggered once the control completes (going to the function and do whatever) the main animation block (Having said the function inside the main animation block does have a different time duration). Hence, the function inside the completion block gets executed with the DURATION_Z and it does animate for the exact duration mentioned in DURATION_Z.
Along the side, the function inside the main animation block gets executed for the time duration specified in the DURATION_X ONLY. It ignores the time duration of DURATION_Y. A wacky code snippet here is:
-(void)doSomeAnim
{
[UIView animateWithDuration:5.0
animations:^
{
[self animateOrangeBoy];
}
completion:^(BOOL finished)
{
[self animateBlueBoy];
}];
}
-(void)animateOrangeBoy
{
[UIView animateWithDuration:20.0 animations:^{
orangeView.frame = CGRectMake(orangeView.frame.origin.x, orangeView.frame.origin.y + 300, orangeView.frame.size.width, orangeView.frame.size.height);
}];
}
-(void)animateBlueBoy
{
[UIView animateWithDuration:10.0 animations:^{
blueView.frame = CGRectMake(blueView.frame.origin.x, blueView.frame.origin.y + 300, blueView.frame.size.width, blueView.frame.size.height);
}];
}
So, animateBlueBoy
also starts along with the animateOrangeBoy
but animateOrangeBoy
lasts only 5 seconds but animateBlueBoy
goes till 10 seconds.