Rylaris
Rylaris

Reputation: 43

How to use systemColor in the opposite way

I want to use systemColor in the opposite way in iOS13 UIColor, for example, systemGray6 is (242,242,247) in LightMode and (28,28,30) in DarkMode, but I want to use (242,242,247) in DarkMode and (28,28,30) in LightMode. What should I do? Apple says:

Don't hard-code system color values in your app. The color values provided below are intended for reference during your app design process. The actual color values may fluctuate from release to release, based on a variety of environmental variables. Always use the API to apply system colors; for developer guidance, see UIColor.

so how can I use systemColor in the opposite way and avoid hard-code system color values?

Upvotes: 0

Views: 225

Answers (1)

Dilan
Dilan

Reputation: 2688

Simple Answer is create new colour set

First go to your project Assets .Add new colour set.

Then change it's appearance to Any,Dark,Light. set colours what you want in light or dark.

Now you use this colour in anywhere as color

something.color = UIColor(named:"myColor")

Create new color set change appearance set colors

Upvotes: 2

Related Questions