I’d like to do two animations, one after the other:
[UIView beginAnimations:@"growImage" context:nil];
[UIView setAnimationDuration:0.2f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDelegate:self];
image6.transform = CGAffineTransformMakeScale(0.9, 0.9);
[UIView commitAnimations];
[UIView beginAnimations:@"shrinkImage" context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDelegate:self];
image6.transform = CGAffineTransformMakeScale(0.1, 0.1);
[UIView commitAnimations];
I know that I can do the second animation in
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
or by setting a
[UIView setAnimationDidStopSelector:@selector(shrinkImage)];
But is there a way that I can pass in the value (in this case a UIIMageView named image6) so that the second animation occurs on the same object as the first one?
THANKS!
If you want to use the selector-based approach, the selector that you specify in the
setAnimationDidStopSelectorgets passed acontextparameter that you specify in yourbeginAnimations:context:call.So, if you change your beginAnimations call to:
then
image6will get passed as the context parameter to your selector.An easier way would be to use blocks to accomplish the same thing: