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

查看:22
本文介绍了有没有办法执行 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 的包袱还有其他方法吗?想法?

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天全站免登陆