我正在使用 foll 呈现一个 View Controller 。代码:
VC_B * b = [[VC_B alloc] init...];
[self presentViewController:b animated:YES completion:nil];
我正在尝试为 View Controller 的外观设置动画:传入的 VC 应该从覆盖当前显示的 VC 的顶部向下滑动。以下 this解决方案使它解决了一个问题:在传入的 VC 出现在屏幕上之前,当前的 VC 消失了。有办法解决这个问题吗?也许有另一种解决方案可以实现这种效果。
最佳答案
试试这段代码:
CreateNewViewController *newViewController = [[CreateNewViewController alloc]initWithNibName:@"CreateNewViewController" bundle:nil];
CATransition *transition = [CATransition animation];
transition.duration = 0.05;
transition.timingFunction = [CAMediaTimingFunction
functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type =kCATransitionMoveIn;
transition.subtype =kCATransitionFromTop;
transition.delegate = self;
[self presentModalViewController:newViewController animated:NO];
[self.view insertSubview:newViewController.view atIndex:0];
[self.view.layer addAnimation:transition forKey:nil];
希望这对您有所帮助。
关于ios - 使用自定义动画呈现 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16377799/