passing nil to `perferredColorScheme` instead of light/dark

The view modifier .preferredColorScheme takes the optional ColorScheme?. I expected if you pass nil it would just use the system light/dark settings, but it's not working that way for me and I can't find any information in the docs or headers.

Does anyone know?

Answered by BabyJ in 669114022
This has been resolved iOS 14.5 beta 2. You can view the release notes for more information on new features and resolved issues.

Setting .preferredColorScheme(nil) now correctly resets to the system’s preferred color scheme. (67000774)

If you are not using the latest beta software or Xcode releases then you will have to wait for the final release of iOS 14.5 which should be available in a couple of weeks.



Accepted Answer
This has been resolved iOS 14.5 beta 2. You can view the release notes for more information on new features and resolved issues.

Setting .preferredColorScheme(nil) now correctly resets to the system’s preferred color scheme. (67000774)

If you are not using the latest beta software or Xcode releases then you will have to wait for the final release of iOS 14.5 which should be available in a couple of weeks.



Awesome, I'm using the regular 12.4 release and this feature can wait. Thanks @BabyJ.

It's not completely resolved on macOS. If you apply .preferredColorScheme(nil) while set to a specific theme, the background color will change, but text and other colors will remain as the last theme color.

After clicking another window, it changes normally.

I am not sure if the problem was ever resolved, but it definitely happens on iOS 18 & macOS Sequoia

passing nil to `perferredColorScheme` instead of light/dark
 
 
Q