i want to create a custom animation for the animation of the pushViewController
using a sequence of images.
I have done this up to the point the the currentViewController
is covered with the images i want but i don't know if i's possible to reveal the nextViewController
when trying to reverse the order of the animation images.
so far i have the following
- (IBAction)nextAction:(id)sender {
UIImage* img1 = [UIImage imageNamed:@"image-1.png"];
UIImage* img2 = [UIImage imageNamed:@"image-2.png"];
UIImage* img3 = [UIImage imageNamed:@"image-3.png"];
UIImage* img4 = [UIImage imageNamed:@"image-4.png"];
UIImage* img5 = [UIImage imageNamed:@"image-5.png"];
NSArray *animationImages = [NSArray arrayWithObjects:img1,img2,img3,img4,img5,nil];
CALayer *myLayer = [CALayer layer];
myLayer.bounds = CGRectMake(0.0, 0.0, 320.0, 480.0);
myLayer.position = self.view.center; //CGPointMake(0.0 ,0.0);
CAKeyframeAnimation *animationSequence = [CAKeyframeAnimation animationWithKeyPath: @"contents"];
animationSequence.calculationMode = kCAAnimationLinear;
animationSequence.autoreverses = NO;
animationSequence.duration = 0.4;
animationSequence.delegate = self;
animationSequence.repeatCount = 1; //HUGE_VALF;
NSMutableArray *animationSequenceArray = [[NSMutableArray alloc] init];
for (UIImage *image in animationImages)
{
[animationSequenceArray addObject:(id)image.CGImage];
}
animationSequence.values = animationSequenceArray;
[myLayer addAnimation:animationSequence forKey:@"contents"];
[self.view.layer addSublayer:myLayer];
}
- (void)animationDidStop:(CAAnimation*)animation finished:(BOOL)finished {
NextViewController *nextViewController;
nextViewController = [[NextViewController alloc] initWithNibName:@"NextViewController" bundle:nil];
nextViewController.title = @"next";
[self.navigationController pushViewController:nextViewController animated:NO];
[nextViewController release];
}
the IBAction
nextAction
is executed when the user presses a button and the images get animated on top of the current view.
What i want to achieve is after the images are on top, push the nextViewController
under the images and reverse the animation so the nextViewController
gets revealed.
I hope this makes sense. It's just like having a photo, placing a number of cards on top of the photo and then removing the cards revealing a different photo.
Teo