如何使用故事板进行水平封面转场? [英] How to do a horizontal cover segue using storyboards?

查看:41
本文介绍了如何使用故事板进行水平封面转场?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个垂直的封面过渡.我一直在网上寻找如何做水平封面但没有成功.有什么建议吗?

There is a vertical cover transition. I have been looking around the web for how to do a horizontal cover with no success. Any suggestions?

推荐答案

iOS 中没有提供水平覆盖过渡.您必须创建自己的 UIStoryboardSegue 子类并实现自己的过渡动画.

There's no horizontal cover transition provided in iOS. You'll have to create your own UIStoryboardSegue subclass and implement your own transition animation.

我认为您正在寻找的过渡动画的一种方法是这样的(警告:未经测试的代码):

One way to animate the kind of transition I think you're looking for is something like this (warning: untested code):

// add newView to window
[oldView.window insertSubview:newView aboveSubview:oldView];

// assuming newView and oldView both sized to fill screen,
//   position newView just to the right of oldView
newView.center = oldView.center + oldView.frame.size.width;

// slide newView over oldView, then remove oldView
[UIView animateWithDuration:0.3
                 animations:^{ newView.center = oldView.center; }
                 completion:^(BOOL finished){ [oldView removeFromSuperview]; }];

这篇关于如何使用故事板进行水平封面转场?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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