How to create a color picker button like Apple does in Pages / Numbers / Keynote

Viewed 44

I want to create a color picker button like Apple does in Pages / Numbers / Keynote :

enter image description here

It has a bezel border like push button, with left part filled by selected color, and right part clickable to show system color picker.

Here are what I tried before:

  1. set NSButton.wantsLayer to true and set a background color to layer to show the color. two problems:

    a. the bezel border is gone

    b. I don't know how to add the right part to button

  2. create a new NSView and add custom sub views. two problems:

    a. don't know how to draw bezel border just like push button

    b. it's difficult to keep same size with push button

0 Answers
Related