有没有办法执行 UIModalTransitionStyleCoverHORIZONTAL(不是 FlipHorizo​​ntal)?

is there a way to perform UIModalTransitionStyleCoverHORIZONTAL (not FlipHorizontal)?(有没有办法执行 UIModalTransitionStyleCoverHORIZONTAL(不是 FlipHorizo​​ntal)?)
本文介绍了有没有办法执行 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)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
How to stop UIBarButtonItem text from truncating?(如何阻止UIBarButtonItem文本被截断?)
java.lang.IllegalStateException: SimpleTypeImpl should not be created for error type(异常:不应为错误类型创建SimpleTypeImpl)
Android IllegalArgumentException: The tag for fragment_XXX is invalid. Received: layout-sw600dp/fragment_XXX_0(Android IlLegalArgumentException:Fragment_XXX的标签无效。收到:Layout-sw600dp/Fragment_XXX_0)
iOS convert audio sample rate from 16 kHz to 8 kHz(IOS将音频采样率从16 kHz转换为8 kHz)
Enforcing an audio sampling rate in iOS(在iOS中强制音频采样率)