In iOS 12 and before I used [[UINavigationBar appearance] setBackgroundColor...]
to set a app wide background color for all NavBars.
In iOS 13 I would like to do the same while supporting Dark Mode. In the apps Asset Catalog I defined a named Color NavBarBackground
and specified both a Any appearance
and Dark appearance
color.
If the Dark Mode is disabled the correct Any
color is used. However when Dark Mode is enabled the specified Dark
color is ignored and all NavBar appear in plain black...
However, if I set the background color of a NavBar manually in IB to NavBarBackground
this one NavBar shows the correct color both in Normal and in Dark Mode.
So, how to use [UINavigationBar appearance]
together with Dark Mode and named colors?
if #available(iOS 13.0, *) { // disable dark mode window?.overrideUserInterfaceStyle = .light }
it will change the light to entire app – Anbu.Karthik