iOS Question userInterfaceStyle is always 1 = light mode

Alexander Stolte

Expert
Licensed User
Longtime User
I'm using the following code to check if the user is using a dark mode or the light mode.
If i have the light mode the result is 1, but if i have the dark mode on, then the returning number is a 1 too.

B4X:
Public Sub IsDarkMode As Boolean
    Dim app As Application
    If app.OSVersion < 13 Then Return False
    Dim no As NativeObject = app.KeyController
    Return no.GetField("traitCollection").GetField("userInterfaceStyle").AsNumber = 2
End Sub

Tested on simulator and a real device
 
Solution
Have you added: #PlistExtra: <!--<key>UIUserInterfaceStyle</key>-->
?

Without it, dark mode will be disabled for your app.
Top