Reputation: 11
I am attempting to add a dark mode to my app and I have it almost done but I am having trouble with this one piece. When I call
self.present(vc, animated: true, completion: nil)
my image below pops up in front of my previous view. However, the top coloring is white still instead of dark. I have tried numerous different background color changes but can't seem to find the correct layer to change the background on. Does anyone know what layer this is to so I can change it to black to complete my dark mode?
Upvotes: 0
Views: 435
Reputation: 119992
Although that should be black
by default, it's window
's background view. So you can change it to any color you want:
view.window?.backgroundColor = .yellow
Note that you can use .systemBackground
as color. so it's automatically the correct color in either light or dark mode.
And also note that the window color only needs to be set once (per window). Set it in the App/Scene delegate and be done
All views have access to their window
Thanks to @rmaddy for the notes
Upvotes: 0