简体   繁体   中英

Dark Mode IOS overrideUserInterfaceStyle is not applied

            overrideUserInterfaceStyle = .dark

I have several viewControllers using this code but darkMode is not applied with this code. Is being used in viewDidLoad

if you wanted to this in a UIViewController, you would just do this.

 overrideUserInterfaceStyle = .dark

Again, we assign either a light a dark value (usually within viewDidLoad() ).

Window

If we need to access the current window, we could do so as follows:

for window in UIApplicationl.shared.windows {
    window.overrideUserInterfaceStyle = .dark
}

(This is not a recommended approach and you would be hard-pressed to find any real reason to want to do this...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM