If your application doesn’t have the support of the dark mode then you should consider turning off the dark mode for your app. If you don’t do this then your app will give a bad user experience in the dark mode, some common problem with text sometimes they just don’t show in the dark mode in UILabel
, UITextField
, UITextView
, etc.
The app that has support below iOS 13
Open your AppDelegate class
and write below code in didFinishLaunchingWithOptions
function
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
#if compiler(>=5.1)
if #available(iOS 13.0, *) {
// Always adopt a light interface style.
window?.overrideUserInterfaceStyle = .light
}
#endif
return true
}
The app which has support iOS 13 and above
Open the SceneDelegate class
and in willConnectTo
function make below changes.
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
#if compiler(>=5.1)
if #available(iOS 13.0, *) {
// Always adopt a light interface style.
window?.overrideUserInterfaceStyle = .light
}
#endif
guard let _ = (scene as? UIWindowScene) else { return }
}
We recommend you turn off the dark mode using the above code if your app doesn’t have the support of it otherwise, it leads to the bad user experience.
Read our next article: Custom URL Scheme | Deep-Link iOS 13 and later Swift 5