有没有一种方法可以执行UIModalTransitionStyleCoverHORIZONTAL(不是FlipHorizo​​ntal)? [英] is there a way to perform UIModalTransitionStyleCoverHORIZONTAL (not FlipHorizontal)?

查看:91
本文介绍了有没有一种方法可以执行UIModalTransitionStyleCoverHORIZONTAL(不是FlipHorizo​​ntal)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Objective-C(很明显,我猜),我想知道是否存在一种(简单的)方式来呈现模态视图,但视图从屏幕右侧滑入

I'm using objective-c (obviously, I guess) and I'm wondering if there is a (simple) way to present a modal view but have the view slide in from the right side of the screen.

UIModalTransitionStyleCoverVertical 从底部插入了新的视图幻灯片,因此我天真地认为会有水平"副本,但是我在文档中找不到.

UIModalTransitionStyleCoverVertical has the new view slide in from the bottom, so I would naively think that there would be a Horizontal counterpart, but I can't find one in the docs.

我的意思不是 UIModalTransitionStyleFlipHorizo​​ntal (我不希望3D翻转).

I don't mean UIModalTransitionStyleFlipHorizontal (I don't want the 3D flip).

还有没有UINavigationController的包do做这件事的另一种方法吗?有想法吗?

Is there another way to do this without the baggage of a UINavigationController? Thoughts?

TKS!

推荐答案

您可以通过以下方式进行操作:将视图添加为子视图,但是将其转换方式设置为使其位于屏幕外,即在您的屏幕上至少保留一个屏幕宽度案子.然后启动一个动画块,其中包括将变换重置为单位.动画制作完成后,您可以执行其他操作,例如替换现在隐藏的视图.

You can do this by adding the view as a subview, but setting its transform so that it is positioned off-screen, by at least one screen width in your case. Then start an animation block that includes resetting the transform to unity. Once the animation is complete you can perform other actions, such as replacing the view that is now hidden.

这是一个代码段:

[[outgoingView superview] insertSubview:incomingView aboveSubview:outgoingView];
incomingView.transform = [self affineTransformForTransationInDirection:BTRightDirection];

// Set up and start the animation
[UIView beginAnimations:@"cover" context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:BTSCREEN_ANIMATION_TIME];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(coverIncomingViewConclusion:finished:context:)];
incomingView.transform = CGAffineTransformIdentity;
self.outgoingView = outgoingView;   // Remember the outgoing view
[UIView commitAnimations];

方法affineTransformForTransationInDirection:是一个帮助程序,它知道屏幕的宽度和高度并返回适合该方向的变换.这样做是为了向左移动:

The method affineTransformForTransationInDirection: is a helper that knows the width and height of the screen and returns a transform appropriate for the direction. It does this for a move in from the left:

CGAffineTransformMakeTranslation(-FHScreenWidth(), 0.0);

这篇关于有没有一种方法可以执行UIModalTransitionStyleCoverHORIZONTAL(不是FlipHorizo​​ntal)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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