Let’s make our app stand out with custom accent colors, and verify that it works nicely in light, dark, and high contrast mode.
Deprecated Way
This method still works, but has been deprecated. Let’s define the AccentColor in Assets instead.
ContentView()
.accentColor(Color.purple)
New Way
Steps
- In the Xcode Navigator…
- Select Assets
- Select AccentColor
We can set custom colors for different devices and display modes, but let’s use a system color for now. Using a provided system color means the OS handles all the different display modes for us.
- Select Universal
- Set the universal color to
systemPurpleColor
Resources
HIG: Visual Design Color .systemPurple
Diff
{
"colors" : [
{
+ "color" : {
+ "platform" : "universal",
+ "reference" : "systemPurpleColor"
+ },
"idiom" : "universal"
}
],