gpt4 book ai didi

ios - View Controller 透明背景

转载 作者:可可西里 更新时间:2023-11-01 00:13:35 28 4
gpt4 key购买 nike

如何创建一个具有透明背景的 View Controller ,该 View Controller 覆盖另一个 View Controller ,而底部 View Controller 在 iOS 9 中仍然可见?在 iOS 8 中的工作方式不再有效。

最佳答案

首先你可以设置overlaid view controller的背景颜色为clear color。

您可以使用 presentViewController 方法覆盖新的 View Controller 。

这来自苹果文档

当使用 UIModalPresentationFullScreen 样式呈现 View Controller 时,UIKit 通常会在过渡动画完成后移除底层 View Controller 的 View 。您可以通过指定 UIModalPresentationOverFullScreen 样式来防止删除这些 View 。

因此您可以将重叠 View Controller 的 modalPresentationStyle 设置为 UIModalPresentationOverFullScreen

我也希望这可能对您有所帮助

当使用其中一种全屏演示样式时,启动演示的 View Controller 本身必须覆盖整个屏幕。如果呈现 View Controller 没有覆盖屏幕,UIKit 会沿着 View Controller 层次结构向上走,直到找到一个覆盖屏幕的 View Controller 。如果找不到填充屏幕的中间 View Controller ,UIKit 将使用窗口的 Root View Controller 。

关于ios - View Controller 透明背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33019165/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com