I have 2 subviews that take the whole screen (excepted the status bar). Let's call this size "screen size".
I want to animated both :
the first to zoom from a little bit larger than the screen size to the screen size, from alpha 0 to alpha 1.
The second from screen size to a little bit smaller than screen size, from alpha 1 to alpha 0.
The second view is visible and on screen at start.
I wrote this :
- (void) switchViews
{
if (self.view2Controller == nil) {
self.view2Controller = [[View2Controller alloc] initWithNibName:@"View2XIB" bundle:nil];
self.view2Controller.view.hidden = YES;
[self.view addSubview:self.view2Controller.view];
}
CGRect bigFrame = CGRectInset(self.view.frame, -50, -50);
CGRect normalFrame = self.view.frame;
CGRect smallFrame = CGRectInset(self.view.frame, 50, 50);
self.view2Controller.view.frame = bigFrame;
self.view2Controller.view.alpha = 0.0;
[UIView beginAnimations:@"Anim1" context:nil];
[UIView setAnimationDuration:5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
self.view2Controller.view.hidden = NO;
self.view2Controller.view.frame = normalFrame;
self.view2Controller.view.alpha = 1.0;
[UIView commitAnimations];
// ------------------------------
[UIView beginAnimations:@"Anim2" context:nil];
[UIView setAnimationDuration:5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.view cache:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)];
self.view1Controller.view.frame = smallFrame;
self.view1Controller.view.alpha = 0.0;
[UIView commitAnimations];
}
Of course, I've tried first to put both animations into an unique one. That does not change anything, that's why I tried to separate them.
When launched, view1 goes immediatly to black, then the view2 starts animating as expected. But I can't achieve to run both animations at the same time.
How would I do that ?