Yes, you can use the colorScheme environment variable to dynamically change the background color based on the user’s chosen color scheme. Here is an example:
In this example, we are using a custom color named “Background” for the background color. We then use the colorScheme environment variable to set the color scheme based on the user’s chosen mode (light or dark). The colorScheme variable is determined using the userInterfaceStyle property of the traitCollection of the main screen.