首页 > 解决方案 > Swift iOS App 如何在 UITabBarController 上显示 UIView

问题描述

我有一个带有 3 个 ViewController 的 iOS 应用程序,如果用户未登录,则在我的第一个 ViewController 上显示一个弹出窗口,该弹出窗口用黑色 UIView(不透明度 50%,如 UIAlertController)和 2 个按钮(注册或登录)覆盖所有屏幕)。

问题是,tabBar 总是在我的 UIView 上,我想在 tabBar 上显示...(由于不透明度,我不能仅仅隐藏 tabBar,我仍然想在我的黑色不透明度 50% 下看到 tabBar看法。

我尝试使用图层的 zPosition 但这不起作用。

任何想法 ?

谢谢

标签: iosswiftalerttabbar

解决方案


这将是正确的方法:

/* Add dialog to main window */
guard let appDelegate = UIApplication.shared.delegate else { fatalError() }
guard let window = appDelegate.window else { fatalError() }
window?.addSubview(self)
window?.bringSubview(toFront: self)
window?.addSubview(**Your view**)
window?.endEditing(true)

推荐阅读