我想为pushViewController
使用一系列图像的动画创建自定义动画。
我已经做到了这一点,currentViewController
上面覆盖了我想要的图像,但我不知道我是否可以nextViewController
在尝试反转动画图像的顺序时显示。
到目前为止,我有以下
- (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];
}
IBAction
nextAction
当用户按下一个按钮并且图像在当前视图之上动画化时执行。
我想要实现的是在图像位于顶部之后,推动nextViewController
图像下方并反转动画,以便nextViewController
显示出来。
我希望这是有道理的。这就像有一张照片,将一些卡片放在照片上,然后取出卡片,露出另一张照片。
张