Varun Naharia
Varun Naharia

Reputation: 5420

iOS dark light mode not updating UIViewController

I am facing problem with a iOS project with Xcode 12.3. App is designed for both light and dark mode and it is working fine if we are changing light/dark mode while app is closed but if send app in background and change mode and resume app then current UIViewController not updating dark/light mode. You can check that in below.

http://g.recordit.co/0LtJsLLkfe.gif

Upvotes: 1

Views: 1767

Answers (1)

HD Mavani
HD Mavani

Reputation: 81

When User Interface Style is changed then system call func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) this delegate methods

please refresh your programatic assigned colors in this methods

   override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
        super.traitCollectionDidChange(previousTraitCollection)
        if(traitCollection.userInterfaceStyle == .dark){
            // set your Dark UI
        } else {
            // set your Light UI
        }
    }

Upvotes: 1

Related Questions