Currently, by using this code.
Button(action: { }) {
Image(systemName: "xmark.circle.fill")
.imageScale(.large)
.foregroundColor(Color(UIColor.lightGray))
}
My button will have
- Transparent color cross mark
- Light gray background
However, what if I would like to achieve
- Black color cross mark
- Light gray background
which looks like
May I know how I can achieve such? Thanks.
2
Answers
Set the modifier
symbolRenderingMode
topalette
and then select the colours you wantUse code like this:
Just know that you’ll have to define a color called
lightGray
in your assets file.Here’s an image:
That said, you should really consider using colors that adjust for the display mode (dark or light) and names that match. It’s trivial to define alternate colors in the assets file,