I want to share an alternative way to define dynamic colors in Asset catalog,
but no need to write tedious code like
Color("yellow")
1. Define your color in asset catalog as usual
2. In your code, find a place to define your color as a variable, in my case it’ll be something like this:
extension Color {
static let ui = Color.UI()
struct UI {
let yellow = Color("yellow")
}
}
3. Finish
Use your color like this:
Text("Hello").background(Color.ui.yellow)
This only requires writing hard-coded color in your code for only 1 time.