Swift Navigation Bar not change userInterfaceStyle on scoll

63 Views Asked by At

I have a problem when I try to change interface style (dark or light). If I set dark mode I get the navigation bar remains light when I scroll. If I set light mode the navigation bar becomes black. How can I solve this? I use this code to change userInterfaceStyle:

window?.overrideUserInterfaceStyle = .dark

enter image description here

1

There are 1 best solutions below

0
On

I found a solution by myself. For everyone that has this problem the solution is:

let appearance = UINavigationBarAppearance()
    appearance.configureWithOpaqueBackground()
    appearance.backgroundColor = .systemBackground
    UINavigationBar.appearance().standardAppearance = appearance
    UINavigationBar.appearance().scrollEdgeAppearance = UINavigationBar.appearance().standardAppearance

put this code inside TabBarController