Name
NSColorPanel — Mac OS X 10.0
Synopsis
This class implements the system-wide color picker used by all
applications. To obtain the shared color panel, use the class method
sharedColorPanel
. NSColorPanel
is a subclass of NSPanel
, so to display the color
panel on screen, invoke
NSWindow
’s
orderFront
: method.
NSColorPanel
takes a target and an action that are
used to notify the application of the user changing the color
selection in the color panel. To obtain the color, use the method
color
.
The color panel optionally displays a slider to change the alpha
value of the selected color. This behavior is set with the method
setShowsAlpha
:. To determine if the color panel is
set to use alpha, invoke showsAlpha
. It is also
possible for an application to add a color list—which is an
instance of NSColorList
—to the color panel.
Color lists are managed using the methods
attachColorList
: and
detachColorList
:.
The Application Kit provides the class NSColorWell
as an interface to Cocoa’s color-picking system. It
is generally sufficient to use NSColorWell
as an
interface for users to select colors in an application, as it both
displays the color associated with it, and provides a means to open
the color panel so the user can choose a new color.
|
@interface NSColorPanel : NSPanel
|
// Accessor Methods
|
- (void)setAction:(SEL)aSelector; |
- (void)setColor:(NSColor *)color; |
- (NSColor *)color |
Get Cocoa in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.