1

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

Color("backgroundTheme").opacity(0.3)

How can I do?

Paul
  • 3,644
  • 9
  • 47
  • 113

1 Answers1

2

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)
Raja Kishan
  • 16,767
  • 2
  • 26
  • 52
  • A curiosity why inside an AppDelegate function I can't read the color correctly. This changes appearance from light to darkmode, for him it remains light. – Paul Aug 11 '21 at 14:58