有没有一种方法可以执行UIModalTransitionStyleCoverHORIZONTAL(不是FlipHorizo​​ntal)?

编程入门 行业动态 更新时间:2024-10-25 15:35:11
本文介绍了有没有一种方法可以执行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)?

本文发布于:2023-07-19 19:52:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1159835.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方法   UIModalTransitionStyleCoverHORIZONTAL   ntal   FlipHorizo

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!