-2

Currently I can change the background color of my window like so:

tab_view.layer?.backgroundColor = NSColor(red: 0.9, green: 0.9, blue: 0.9, alpha: 1).CGColor

Which is great and all, but I want the user to be able to change the color. This is when I found out about NSColorWell.

I tried applying the color like so:

tab_view.layer?.backgroundColor = NSColorWell

but then it says "Can't assign value of type 'NSColorWell.Type' to type 'CGColor'?" I tried looking it up, but everything I found (which was barely any) was written in Objective - C

Someone please explain to me how I can make the view background color a color from the NSColorWell.

Critical
  • 45
  • 10

1 Answers1

1

You need to pass NSColorWell .color .CGColor property value. Apple docs

Leo Dabus
  • 229,809
  • 59
  • 489
  • 571
  • I typed it like this but it is not working still. `tab_view.layer?.backgroundColor = NSColorWell().color.CGColor` – Critical Feb 19 '16 at 01:15
  • This is not actual code. You need to pass `yourNSColorWell.color.CGColor` check this answer http://stackoverflow.com/a/31214482/2303865 you need to set wantsLayer = true – Leo Dabus Feb 19 '16 at 01:16