ios - 如何将新添加的 UIWindow 保持在顶部

标签 ios swift uiwindow

在我的应用程序中有一些要求,我需要为一些额外的功能添加新窗口,我能够成功地做到这一点。启动应用程序后,我根据要求添加和关闭窗口。但我想知道如何让当前窗口始终位于其他窗口之上以避免冲突?在 iOS 中有什么方法可以让呈现窗口始终位于其他窗口之上?

最佳答案

看看makeKeyAndVisible API

func makeKeyAndVisible()

Shows the window and makes it the key window.
This is a convenience method to show the current window and position it in front of all other windows at the same level or lower. If you only want to show the window, change its isHidden property to false.

另外,UIApplication.windows property , 这是可见窗口和隐藏窗口的数组

var windows: [UIWindow]

你可以迭代这个数组并找到一个你要设置为关键窗口的窗口。

最后看看 .windowLevel UIWindow property , 它管理窗口在 z 轴上的位置。

var windowLevel: UIWindow.Level { get set }

Window levels provide a relative grouping of windows along the z-axis. All windows assigned to the same window level appear in front of (or behind) all windows assigned to a different window level. The ordering of windows within a given window level is not guaranteed.

The default value of this property is normal. For a list of other possible window levels, see UIWindow.Level.

关于ios - 如何将新添加的 UIWindow 保持在顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50967280/

相关文章:

ios - NSAttributedString 中的一个单词有两种不同的颜色

ios - Swift iOS - 如何在两个 UIWindows 之间切换/切换并制作 keyWindow

ios - LoadView 永远不会在 UIViewController 上调用

ios - 从另一个 VC : Swift 向 JSQCollectionView 添加消息

iphone - IO6 不调用 -(BOOL)shouldAutorotate

objective-c - objective-c 中的所有属性的 setter/getter 都一样吗?

ios - 与 ","分开?

ios - 在不显示选项卡栏的情况下执行到另一个导航 Controller 的转场

swift - 当我使用map.clear()时如何再次显示标记

ios - 将 UIWindow rootViewController 从 UIViewController 重新分配给包含 UINavigationControllers 的 UITabBarController