I referred to the DOC and it said:
completion
... This block has no return value and takes a single Boolean argument that indicates whether or not the animations actually finished before the completion handler was called. ...
But I find that no matter you use the bool parameter or not, the completion:
block will always execute after animations:
block. Just like the two simple block-based animation code snippets shown below, both of them are doing the same.
[UIView animateWithDuration:0.3f
delay:0.0f
options:UIViewAnimationCurveEaseInOut
animations:^{
[myView setAlpha:0.0f];
}
completion:^(BOOL finished) {
[myView removeFromSuperview];
}];
and
[UIView animateWithDuration:0.3f
delay:0.0f
options:UIViewAnimationCurveEaseInOut
animations:^{
[myView setAlpha:0.0f];
}
completion:^(BOOL finished) {
if (finished) [myView removeFromSuperview];
}];
And I find that most people(including me) use the first one(even the apple's official doc example). So,
- what's the
finished
parameter used for here exactly? - or what's the situation will be used?