切换 `UITabBarController` 选项卡时删除黑色背景

remove black background when switching tab of `UITabBarController`

UITabBarController 有 4 个选项卡。在第一个选项卡的 ViewController 中,我使用 popUpVC.modalPresentationStyle = .overCurrentContext

显示了 Popup

所以我得到了这个(那是我想要的完美):

但是现在当我切换到secondTabDollor_Icon,然后立即回到firstTab...我得到了blackBG而不是透明背景。 像这样:

我的模态表示代码:

let popUpVC = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "PopUp")
popUpVC.modalPresentationStyle = .overCurrentContext
self.present(popUpVC, animated: true)

希望摆脱黑色背景,为什么会这样?
谢谢!

将此添加到您的 firstTabViewController ViewDidLoad() 方法:

    definesPresentationContext = true

希望您的问题得到解决。

有关 definesPresentationContext 的更多详细信息,请参阅 https://developer.apple.com/documentation/uikit/uiviewcontroller/1621456-definespresentationcontext'