I am still using the xcode 10.2.1 and haven't upgraded to xcode 11 because of some other issues. Now I want to detect that users who are using iOS 13 has chosen dark mode or light mode as their app settings.
As per apple document, If developer build app through previous xcode the app would be in light mode by default, which is my case and is fine.
So, is there a way to detect the user current appearance mode.
There is code snippet which I am using:
if #available(iOS 13.0, *) {
guard(traitCollection.responds(to: #selector(getter: UITraitCollection.userInterfaceStyle)))
else { return }
let style = traitCollection.userInterfaceStyle
switch style {
case .light:
print("light")
case .dark:
print("dark")
case .unspecified:
print("unspecified")
@unknown default:
print("unspecified")
}
}
But it is always returning unspecified or light.