Hello,
Today I’m playing with Gradient and custom colors. I can’t seem to figure out the syntax to use a custom color and a Gradient tho.
I’ve created 3 custom colors in my assets. botBlue, botGreen, botOrange, botPurple, and I’ve tried to use them in the examples below, all of which do not compile.
.background(LinearGradient(gradient: Gradient(colors: [Color(mobColors.botBlue), Color.green]), startPoint: .top, endPoint: .bottom))
…
.background(LinearGradient(gradient: Gradient(colors: [Color(botBlue), Color.green]), startPoint: .top, endPoint: .bottom))
…
.background(LinearGradient(gradient: Gradient(colors: [Color(.botBlue), Color.green]), startPoint: .top, endPoint: .bottom))
I’ve also tried to create a static var and then use the variable name in a Gradient, as follows, but no joy.
struct mobColors {
static let botifyPurple = Color("botPurple")
static let botifyBlue = Color("botBlue")
static let botifyGreen = Color("botGreen")
static let botifyOrange = Color("botOrange")
}
If anyone can advise how I can use custom colors in a Gradient, that would be much appriciated.
Tnank you!