NSColorWell for View Background | Swift OSx

650 views Asked by At

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.

1

There are 1 answers

2
Leo Dabus On BEST ANSWER

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