请看下面的图片,我在我的应用程序中呈现了一个视图控制器,屏幕上出现了3个层次:
编辑:事实证明,第一层并不是由系统提供的,而只是应用程序的关键窗口背景!请参见我的下面的答案。
- 黑色,由系统提供
- 我的应用程序,呈现的视图控制器,白色
- 我的应用程序,展示的视图控制器,白色
![screenshot](https://istack.dev59.com/ej7b2.webp)
我成功解决了这个问题,方法是设置关键窗口的背景颜色,例如:
// inside appDelegate's didFinishLaunchingWithOptions
// The first layer will be white now
window?.backgroundColor = UIColor.white
viewWillAppear
方法中,您需要通过以下代码重置其背景颜色:override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.view.backgroundColor = .white
}
在你推出新视图控制器的位置放置这个:
self.navigationController?.pushViewController(anotherVC, completion: {
self.view.backgroundColor = .black
})