This is easy to reproduce,in dark mode, 2 UIViewControllers A and B, A present B. code:
class AAA: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.title = "AAA"
view.backgroundColor = .systemBackground
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
present(UINavigationController(rootViewController: BBB()), animated: true)
}
}
class BBB: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
navigationItem.title = "BBB"
view.backgroundColor = .systemBackground
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
dismiss(animated: true)
}
}
before present:
after present:
Obviously, the backgroundColor of the view has changed.
I guess it's because view's backgroundColor is the same as the the window, so changed the color to distinguish between the controller and the background, but this brought unexpected changes which is confusing. I want to know how this happened and how I can manually control it