2020年2月8日土曜日

Disable Darkmode programmatically on Swift . iOS 13

Darkmode was introduced on iOS13 and it add the cool appearance on the iOS
however  when you don't want to implement the darkmode because of some design conflict, ui conflict, here is how to disable dark mode.

add following code on viewDidLoad for each viewController as explained

override func viewDidLoad() {
        super.viewDidLoad()

        // Always adopt a light interface style.    
        overrideUserInterfaceStyle = .light
    }



There is the other solution to make light style as a default for all view, which is to add key on info.plist. but this solution is not recommended by apple.

you can temporarily opt out by including the UIUserInterfaceStyle key (with a value of Light) in your app’s Info.plist file. Setting this key to Light causes the system to ignore the user's preference and always apply a light appearance to your app.
Important
Supporting Dark Mode is strongly encouraged. Use the UIUserInterfaceStyle key to opt out only temporarily while you work on improvements to your app's Dark Mode support.

for more information, see the link

0 件のコメント:

コメントを投稿