Search code examples
iosios13

Can overrideUserInterfaceStyle override system alerts / action sheets?


Setting overrideUserInterfaceStyle doesn't seem to override the style for system alerts / action sheets, they can still be light when i set it to .dark, any workaround? Thanks!


Solution

  • It works just fine if you set the overrideUserInterfaceStyle on the main window of your scene.

    Update the willConnectTo method of your scene delegate to set the window's override:

    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Other existing code here
    
        window?.overrideUserInterfaceStyle = .dark // set as needed
    }
    

    This will show your app and various standard controls like action sheets in dark mode no matter which mode is selected in the Settings app.