Xcode 自定义转场 - Cover Vertical 的对面(从上到下) - 完整的新手 [英] Xcode custom segue - Opposite of Cover Vertical (top to bottom) - COMPLETE NEWBIE

查看:34
本文介绍了Xcode 自定义转场 - Cover Vertical 的对面(从上到下) - 完整的新手的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试创建一个与垂直封面相反的自定义转场(创建从上到下的效果动画).我已经浏览了其他问题,谷歌和 YouTube,但无法让它工作.我对课程等完全陌生,因此分步指南或视频中的任何帮助都会非常好.我相信此 URL 正在尝试执行与我想要的类似的操作:

I have been trying for some time to create a custom segue that does the opposite of the cover vertical (to create a from top to bottom effect animation).I had looked through other questions, google and youtube but cannot get it working.I am completely new to the classes etc. so any help in a step by step guide or video would be so good. I believe that this URL is trying to do something similar to what I want:

http:///jrwren.wrenfam.com/blog/2012/02/01/storyboard-custom-segue-for-custom-pushviewcontroller-animation/ ,我就是无法让它工作.

http://jrwren.wrenfam.com/blog/2012/02/01/storyboard-custom-segue-for-custom-pushviewcontroller-animation/ , I just cannot get it working.

如果你们中有人知道如何创建一个从上到下版本的封面垂直转场的转场,您能帮我吗?

If any of you know a way to create a segue that is a top to bottom version of the cover vertical segue could you please help me out?

推荐答案

好吧,您可能想要创建 UIStoryBoardSegue 的子类,就像演练向您展示的那样,但是在 Storyboard 类的 .m 文件(实现)下,您会想要以下代码作为您的 -(void) 执行:方法 -

Well, you would want to create a subclass of UIStoryBoardSegue, like the walkthrough shows you, however under the Storyboard class' .m file(implementation) you would want the following code as your -(void)perform: method -

-(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 的对面(从上到下) - 完整的新手的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆