我一直在尝试创建一个与垂直封面相反的自定义转场(以创建从上到下的效果动画)。我已经浏览了其他问题,谷歌和 youtube,但无法让它工作。我是对类(class)等完全陌生,因此分步指南或视频中的任何帮助都会非常好。我相信这个 URL 正在尝试做一些类似于我想要的事情:
http://jrwren.wrenfam.com/blog/2012/02/01/storyboard-custom-segue-for-custom-pushviewcontroller-animation/ ,我就是无法让它工作。
如果你们中有人知道一种创建从上到下版本的封面垂直转场的转场的方法,您能帮我吗?
最佳答案
好吧,您可能想要创建 UIStoryBoardSegue 的子类,就像演练向您展示的那样,但是在 Storyboard 类的 .m 文件(实现)下,您需要以下代码作为您的 -(void)perform: 方法 -
-(void)perform{
UIViewController *sourceViewController = (UIViewController *) self.sourceViewController;
UIViewController *destinationViewController = (UIViewController *) self.destinationViewController;
[sourceViewController.view addSubview:destinationViewController.view];
[destinationViewController.view setFrame:sourceViewController.view.window.frame];
[destinationViewController.view setTransform:CGAffineTransformMakeTranslation(0, -sourceViewController.view.frame.size.height)];
[destinationViewController.view setAlpha:1.0];
[UIView animateWithDuration:0.75
delay:0.0
options:UIViewAnimationOptionTransitionFlipFromTop
animations:^{
[destinationViewController.view setTransform:CGAffineTransformMakeTranslation(0, 0)];
[destinationViewController.view setAlpha:1.0];
}
completion:^(BOOL finished){
[destinationViewController.view removeFromSuperview];
[sourceViewController presentViewController:destinationViewController animated:NO completion:nil];
}];}
希望这是有帮助的。
关于Xcode 自定义转场 - Cover Vertical 的对面(从上到下) - 完整的新手,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14081880/