Xcode 自定义转场 - Cover Vertical 的对面(从上到下) - 完整的新手

标签 xcode segue

我一直在尝试创建一个与垂直封面相反的自定义转场(以创建从上到下的效果动画)。我已经浏览了其他问题,谷歌和 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/

相关文章:

xcode - 无需使用转场就需要交叉溶解过渡

iphone - 将应用程序提交到 itune connect 使用不同的默认语言然后是英语(未找到应用程序记录。)

ios - 减缓 Push Segue 的转换

ios - Swift - 将来自 API 的数据传递到另一个 View Controller

c - 如何在 Xcode 中为命令行工具程序创建 .app 文件

ios - 异步使用 NSXMLParser 的问题

IOS Swift UICollectionView,我想为每个单元格设置不同的标签?

ios - 自定义 UITableViewCell 不调用 prepareForSegue

ios - 在尝试呈现 UIViewController(而不是 UITableViewController)时如何避免使用 [UITableViewController loadView]

macos - 人工触发 Segue