I figured that I'd get the support for Dark Mode out of the box with UINavigationBar since I use the default opaque color scheme.
I've noticed that when I switch the dark mode setting to ON either from environment in xcode, or command center with the screen brightness shortcut, my UINavigationController navbar background stays white but the title text color does change to the dark mode title color, white. White text on white background. I verified that the label is still there and still white using the Debug View Heirarchy within xcode.
Sometimes, when I rotate then to landscape, the background will update to dark mode color. It isn't consistent. Same goes for the inverse, changing dark to light mode. Dark text on Dark background color.
From a user's perspective, after a swipe-kill and relaunch, the color matches the themes in all orientations and navigation bars.
I have my nav bars set to opaque from storyboard. Is there something else I'm missing that needs to be done? I didn't see anything in the adopting dark mode video from WWDC 19.
Updated Aug 26, 2019
I'm still seeing this behavior in dev beta 8. Created a bug report--hopefully this gets fixed. FB7134275
Is anyone else affected by this? Basic app layout similar to either Phone or Clock app.
UITabBarController (opaque bottom bar) -
UINavigationController (opaque top bar) -
UIViewController
UINavigationController (opaque top bar) -
UITableViewController
This is really non-functional because the title color is changed, but the bar color is not changing.
Update Jan 6, 2020
iOS 13.3 no longer seems to have this issue. I'm not sure in which earlier update this was addressed.
I have this issue too. Very frustrating. I've ended up creating a subclass af UINavigationController that sets the barTintColoer whenever the trait collection changes. It's not pretty, but does the job until Apple fixes it at their end.
class DarkModeAwareNavigationController: UINavigationController {
override init(rootViewController: UIViewController) {
super.init(rootViewController: rootViewController)
self.updateBarTintColor()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.updateBarTintColor()
}
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
self.updateBarTintColor()
}
private func updateBarTintColor() {
if #available(iOS 13.0, *) {
self.navigationBar.barTintColor = UITraitCollection.current.userInterfaceStyle == .dark ? .black : .white
}
}
}