Others have covered how to lighten and darken UIColors in Swift, but I have not seen a good way to programmatically "lighten" and "darken" dynamic SwiftUI Colors
.
I have green Text
using Color(.systemGreen)
that I would like to appear darker on light backgrounds and lighter on dark backgrounds.
- Using the
.contrast()
modifier increases the green's saturation but doesn't really make it darker. - Using the
.brightness()
modifier with a negative makes it darker for both light and dark mode, which doesn't really work for dark mode since it's harder to read.