如何将 UIView 覆盖层放置在模态视图之上?

发布于 2025-01-04 21:20:24 字数 189 浏览 1 评论 0原文

我有一个信息覆盖层,我想将其应用在作为模式呈现的视图控制器之上。我尝试了各种技巧来让覆盖层(透明的 UIView)显示在模态视图控制器上方,但没有任何运气。

唯一取得一些成功的是将覆盖层添加为主 UIWindow 的子视图,但这否定了 UIWindow 提供的许多有用功能(例如与旋转无关的坐标系)。

还有其他方法可以实现此目的吗?

I have an informative overlay that I want to apply above a view controller presented as a modal. I've attempted all sorts of hacks to get the overlay (a transparent UIView) to be shown above the modal view controller without any luck.

The only thing that has had some success is adding the overlay as a subview of the main UIWindow but that negates a number of helpful features that the UIWindow provides (such as a rotation-independent coordinate system).

Is there another way to accomplish this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

朮生 2025-01-11 21:20:24

这就是模态视图的全部要点——它位于顶部。我唯一能想到的就是将其添加为模式视图的子视图。这可能需要您对模态视图进行子类化,并根据您实际使用的内容添加额外的功能

Thats kind of the whole point of a modal view - its on top. The only think i can think of would be to add it as a subview of the modal view. This may require you to subclass the modal view and add in extra functionality there depending on what your actually working with

蓝色星空 2025-01-11 21:20:24

脑海中浮现的一个想法是:

将透明覆盖层放在主视图上,启动模态弹出窗口,再次将透明覆盖层添加到模态弹出窗口中,但偏移它的原点,以便只需要在视图中显示它的那部分。弹出窗口空间将与主视图上方的覆盖层对齐。

您可能在正确着色方面遇到问题,但似乎很快就能尝试。我能想到的唯一缺点是弹出窗口的边框可能会遮挡其中的一些内容。

One idea that pops into mind is this:

Put your transparent overlay over the main view, launch your modal popover, add the transparent overlay again to your modal popover, but offset it's origin so that just that part of it that's needed to show within the popover space will line up with the overlay that's over the main view.

You might have an issue with getting the shading correct, but seems like it would be quick to try. Only downside I can visualize is that the borders of the popover might block some of it out.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文