Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios pushViewController的自定义动画_Ios_Core Animation_Navigationcontroller - Fatal编程技术网

Ios pushViewController的自定义动画

Ios pushViewController的自定义动画,ios,core-animation,navigationcontroller,Ios,Core Animation,Navigationcontroller,我想使用一系列图像为pushViewController的动画创建自定义动画 我已经这样做了,currentViewController上覆盖了我想要的图像,但我不知道在尝试反转动画图像的顺序时是否可以显示nextViewController 到目前为止,我有以下几点 - (IBAction)nextAction:(id)sender { UIImage* img1 = [UIImage imageNamed:@"image-1.png"]; UIImage* img2 =

我想使用一系列图像为
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];

}
当用户按下按钮并且图像在当前视图顶部设置动画时,将执行
iAction
nextAction

我想要实现的是在图像位于顶部后,将
nextViewController
推到图像下方,并反转动画,以便显示
nextViewController

我希望这是有道理的。这就像拥有一张照片,在照片的顶部放置一些卡片,然后移除显示不同照片的卡片


Teo

不要将动画层添加到当前的viewController,而是直接将该层添加到当前的keyWindow。这将隐藏当前的viewController

[[[UIApplication sharedApplication] keyWindow] layer addSublayer:myLayer];
动画的前半部分完成后(或者换句话说,完成正向顺序的完整动画后),删除动画层。用新的viewController替换viewController,并将第二个动画层再次添加到keyWindow上-现在开始动画的后半部分。完成后,将动画层从关键帧窗口中移除

根据应用程序的结构,还可以使用有效位于其他ViewController下方的rootViewController作为动画层的superview/superlayer

[[[[UIApplication sharedApplication] rootViewController] view] layer addSublayer:myLayer];

我正在尝试使用[[[UIApplication sharedApplication]keyWindow].layer addSublayer:myLayer];但是现在有没有办法在动画播放到一半的时候推下一个视频控制器;我假设你的整个演示动画的前半部分实际上是一个完整的动画,如上文所述。