Swift macOS convert Color to NSColor

763 Views Asked by At

I have a Color taken from the asset, I need to convert it to NSColor.

Color("backgroundTheme").opacity(0.3)

How can I do?

1

There are 1 best solutions below

1
Raja Kishan On BEST ANSWER

NSColor already have a Color init. You can use it like

NSColor(Color("backgroundTheme")).withAlphaComponent(0.3)

Or you can get color by name like this

NSColor(named: "backgroundTheme")?.withAlphaComponent(0.3)