Here is implementation of color picker control which is similar to one that used in original Mac applications like Numbers, Pages, Keynote. Original one has lots of small pictures. This control based on NSSegmentedControl and have numbers of useful thinks to know, so it’s not just implementation but also good place to look:
- how to subclass NSSegmentedCell
- how is working NSTrackingArea
- create NSPopover
Easy to use. Just create view and add on your master view:
1
2 |
CLColorPicker *control = [CLColorPicker alloc] initWithFrame:NSMakeRect(100,100, 70, 24)];
[self.view addSubview:control]; |
To get selected color:
1
|
Or set color:
1
|
[control setSelectedColor:yourColor];
|