internal extension Color {
// Assets.xcassets
static var midnightBlue : Color { Color("midnightBlue", bundle: BundleToken.bundle) }
}
internal extension Image {
// Assets.xcassets
static var abc : Color { Image("abc", bundle: BundleToken.bundle) }
}
Color.midnightBlue // Color
Image.abc // Image
Nice, thanks for this!
Note I found this causes issues when I name a colour in my xcassets file with a standard name (e.g. "Red") as this tries to create
Color.red
- which already exists. In my usage I made a slight change to the stencil to produce a local struct called something likeAppColor
, rather than extending the Color struct.(That is I use the
enumName
value like{{accessModifier}} struct {{enumName}}
)