I m trying to chain animation events. The application I m coding for work has a multiple choice quiz. First you pick your multiple choice answer. The quiz view fades away. Then a label ("correct" or "incorrect") fades in and then fades out. Finally the quiz fades back in again. The events are called and handled by a main viewController. I know I can chain events with the setAnimationDelegate and setAnimationDidStopSelector but I think it ll be easier and more clear to simply use setAnimationDelay so that all animations have time to finish before the next one fires.
I made this function that exists in the class that holds the "correct" "incorrect" label.
- (void)showIncorrect:(float)duration withDelay:(float)delay{
labelView.text = @"Incorrect!";
labelView.textColor = [UIColor redColor];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:delay];
[UIView setAnimationDuration:(duration/2)];
self.alpha = 1.0;
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:(duration/2+delay)];
[UIView setAnimationDuration:(duration/2)];
self.alpha = 0.0;
[UIView commitAnimations];
}
Can someone tell my why the first animation block is ignored? I ve tried to nest one animation block into the other and this does not work either.