Consider this basic view animation. It will scale a view down to nothing over the course of 1 second:
[UIView animateWithDuration: 1.0
delay: 0.0
options: UIViewAnimationCurveEaseIn
animations:^{
vw.transform = CGAffineTransformMakeScale(0.0, 0.0);
}
completion:^(BOOL finished) {
if (finished) {
vw.transform = CGAffineTransformIdentity;
}
}
];
What I'd like to do is use this same animation on many different views at different times throughout my app. To do this, I can easily put it in a method, pass in the view I want to zoom. No problem.
The challenge is that I may need to do different things at the completion of the animation depending on the situation. For example, I may want to remove the view from the SuperView in one case, and I may want to move the view to a new location (for zooming in later) in another case.
In a nutshell: How can I notify the caller of my method when the animation completes?
completion:^(BOOL finished) {
if (finished) {
vw.transform = CGAffineTransformIdentity;
// Do something unique here
}
}