Force accessible Color

Looking at Apple's Color Guidelines and taking into account that building my app to work for both light/dark modes I run into an issue where I want to use colors for statuses: red and green. I want to avoid declaring custom colors and I try to use the default ones that adjust for the selected appearance. Unfortunately I noticed that the Color.green does not work well on the default light background of my view (.background(Color (.windowBackgroundColor))) because there is not enough contrast.

I noticed that Apple also lists "Accessible" versions of those colors but these are probably managed dynamically.

My question:

Is there a way to programatically force my app to use the accessible version of a Color (e.g. green)?

Thanks

Forgive me as I'm just sort of spitballing here... the short answer is no I don't think so.

The Apple Documentation on the colorSchemeContrast environment variable tells us if the user is using increased contrast setting on their device.

What you could do is increase the contrast on the color using the .contrast modifier to that specific views color. However it is important to test the edge case that if a user has the A11Y setting which is to increase the contrast enabled, how will that effect your view?

Maybe you use a combination of the environment variable, and the contrast modifier to only apply the increased contrast if the user does not have increased contrast enabled?

I do hope that this helped guide you in some manner.

Force accessible Color
 
 
Q