| Inherits from | |
| Conforms to | |
| Framework | /System/Library/Frameworks/AppKit.framework |
| Availability | Available in Mac OS X v10.0 and later.
|
| Companion guide | |
| Declared in | NSColor.h |
An NSColor object represents a color, which is defined in a color space, each point of which has a set of components (such as red, green, and blue) that uniquely define a color.
Color space
Color components
Various colorWith... and colorUsing... methods.
Preset colors: blackColor, blueColor, and so on.
colorUsingColorSpaceName:Creates an NSColor instance in the specified color space.
setSets the drawing color.
An NSColor object represents color and sometimes opacity (alpha). By sending a set message to an NSColor instance, you set the color for the current drawing context. Setting the color causes subsequently drawn graphics to have the color represented by the NSColor instance.
It is invalid to use an accessor method related to components of a particular color space on an NSColor object that is not in that color space. For example, methods such as redComponent and getRed:green:blue:alpha: work on color objects in the calibrated and device RGB color spaces. If you send such a message to an NSColor object in the CMYK color space, an exception is raised. If you have an NSColor object in an unknown color space and you want to extract its components, you should first convert the color object to a known color space before using the component accessor methods of that color space.
+ colorWithCalibratedHue:saturation:brightness:alpha:
+ colorWithCalibratedRed:green:blue:alpha:
+ colorWithCalibratedWhite:alpha:
+ colorWithCatalogName:colorName:
+ colorWithDeviceCyan:magenta:yellow:black:alpha:
+ colorWithDeviceHue:saturation:brightness:alpha:
+ colorWithDeviceRed:green:blue:alpha:
+ colorWithDeviceWhite:alpha:
+ colorWithCIColor:
+ colorWithColorSpace:components:count:
+ blackColor
+ blueColor
+ brownColor
+ clearColor
+ cyanColor
+ darkGrayColor
+ grayColor
+ greenColor
+ lightGrayColor
+ magentaColor
+ orangeColor
+ purpleColor
+ redColor
+ whiteColor
+ yellowColor
+ alternateSelectedControlColor
+ alternateSelectedControlTextColor
+ colorForControlTint:
+ controlBackgroundColor
+ controlColor
+ controlAlternatingRowBackgroundColors
+ controlHighlightColor
+ controlLightHighlightColor
+ controlShadowColor
+ controlDarkShadowColor
+ controlTextColor
+ currentControlTint
+ disabledControlTextColor
+ gridColor
+ headerColor
+ headerTextColor
+ highlightColor
+ keyboardFocusIndicatorColor
+ knobColor
+ scrollBarColor
+ secondarySelectedControlColor
+ selectedControlColor
+ selectedControlTextColor
+ selectedMenuItemColor
+ selectedMenuItemTextColor
+ selectedTextBackgroundColor
+ selectedTextColor
+ selectedKnobColor
+ shadowColor
+ textBackgroundColor
+ textColor
+ windowBackgroundColor
+ windowFrameColor
+ windowFrameTextColor
– getCyan:magenta:yellow:black:alpha:
– getHue:saturation:brightness:alpha:
– getRed:green:blue:alpha:
– getWhite:alpha:
– getComponents:
– numberOfComponents
– alphaComponent
– blackComponent
– blueComponent
– brightnessComponent
– catalogNameComponent
– colorNameComponent
– cyanComponent
– greenComponent
– hueComponent
– localizedCatalogNameComponent
– localizedColorNameComponent
– magentaComponent
– redComponent
– saturationComponent
– whiteComponent
– yellowComponent
– colorSpaceName
– colorUsingColorSpaceName:
– colorUsingColorSpaceName:device:
– colorSpace
– colorUsingColorSpace:
– blendedColorWithFraction:ofColor:
– colorWithAlphaComponent:
– highlightWithLevel:
– shadowWithLevel:
Returns the system color used for the face of a selected control.
+ (NSColor *)alternateSelectedControlColor
The system color used for the face of a selected control—a control being clicked or dragged. This color can be used where iApp-like highlighting is desired. For general information about system colors, see “Accessing System Colors”.
NSColor.h
Returns the system color used for text in a selected control.
+ (NSColor *)alternateSelectedControlTextColor
The system color used for text in a selected control—a control being clicked or dragged. This color can be used where iApp-like highlighting is desired. For general information about system colors, see “Accessing System Colors”.
NSColor.h
Returns an NSColor object whose grayscale value is 0.0 and whose alpha value is 1.0.
+ (NSColor *)blackColor
The NSColor object.
NSColor.h
Returns an NSColor object whose RGB value is 0.0, 0.0, 1.0 and whose alpha value is 1.0.
+ (NSColor *)blueColor
The NSColor object.
NSColor.h
Returns an NSColor object whose RGB value is 0.6, 0.4, 0.2 and whose alpha value is 1.0.
+ (NSColor *)brownColor
The NSColor object.
NSColor.h
Returns an NSColor object whose grayscale and alpha values are both 0.0.
+ (NSColor *)clearColor
The NSColor object.
NSColor.h
Returns the NSColor object specified by the given control tint.
+ (NSColor *)colorForControlTint:(NSControlTint)controlTint
The control tint for which to return an NSColor object. This is one of the tint settings. For more on control tints, see Using the System Control Tint.
The NSColor object.
NSColor.hReturns the NSColor currently on the given pasteboard.
+ (NSColor *)colorFromPasteboard:(NSPasteboard *)pasteBoard
The pasteboard from which to return the color.
The color currently on the pasteboard or nil if pasteBoard doesn’t contain color data. The returned color’s alpha component is set to 1.0 if ignoresAlpha returns YES.
NSColor.h
Creates and returns an NSColor object using the given opacity and HSB color space components.
+ (NSColor *)colorWithCalibratedHue:(CGFloat)hue saturation:(CGFloat)saturation brightness:(CGFloat)brightness alpha:(CGFloat)alpha
The hue component of the color object in the HSB color space.
The saturation component of the color object in the HSB color space.
The brightness (or value) component of the color object in the HSB color space.
The opacity value of the color object,
The color object.
Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.
+ colorWithCalibratedRed:green:blue:alpha:+ colorWithDeviceHue:saturation:brightness:alpha:– getHue:saturation:brightness:alpha:NSColor.h
Creates and returns an NSColor object using the given opacity and RGB components.
+ (NSColor *)colorWithCalibratedRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha
The red component of the color object.
The green component of the color object.
The blue component of the color object.
The opacity value of the color object.
The color object.
Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.
+ colorWithCalibratedHue:saturation:brightness:alpha:+ colorWithDeviceRed:green:blue:alpha:– getRed:green:blue:alpha:NSColor.hCreates and returns an NSColor object using the given opacity and grayscale value.
+ (NSColor *)colorWithCalibratedWhite:(CGFloat)white alpha:(CGFloat)alpha
The grayscale value of the color object.
The opacity value of the color object.
The color object.
Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.
NSColor.hCreates and returns an NSColor object by finding the color with the specified name in the given catalog.
+ (NSColor *)colorWithCatalogName:(NSString *)listName colorName:(NSString *)colorName
The name of the catalog in which to find the specified color; this may be a standard catalog.
The name of the color. Note that the color must be defined in the named color space to retrieve it with this method.
The color object.
NSColor.h
Converts a Core Image color object to its NSColor equivalent.
+ (NSColor *)colorWithCIColor:(CIColor *)color
The Core Image color to convert.
The NSColor object corresponding to the specified Core Image color.
The method raises if the color space and components associated with color are nil or invalid.
NSColor.h
Returns an NSColor object created from the specified components of the given color space.
+ (NSColor *)colorWithColorSpace:(NSColorSpace *)space components:(const CGFloat *)components count:(NSInteger)numberOfComponents
An NSColorSpace object representing a color space. The method raises if this is nil.
An array of the components in the specified color space to use to create the NSColor object. The order of these components is determined by the color-space profile, with the alpha component always last. (If you want the created color to be opaque, specify 1.0 for the alpha component.)
The number of components in the components array. This should match the number dictated by the specified color space plus one for alpha. This method raises an exception if they do not match.
The color object. If space represents a color space that cannot cannot be used with NSColor objects—for example, a “pattern” color space—the method returns nil.
NSColor.h
Creates and returns an NSColor object using the given opacity value and CMYK components.
+ (NSColor *)colorWithDeviceCyan:(CGFloat)cyan magenta:(CGFloat)magenta yellow:(CGFloat)yellow black:(CGFloat)black alpha:(CGFloat)alpha
The cyan component of the color object.
The magenta component of the color object.
The yellow component of the color object.
The black component of the color object.
The opacity value of the color object.
The color object.
Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0. In PostScript, this color space corresponds directly to the device-dependent operator setcmykcolor.
NSColor.h
Creates and returns an NSColor object using the given opacity value and HSB color space components.
+ (NSColor *)colorWithDeviceHue:(CGFloat)hue saturation:(CGFloat)saturation brightness:(CGFloat)brightness alpha:(CGFloat)alpha
The hue component of the color object.
The saturation component of the color object.
The brightness component of the color object.
The opacity value of the color object.
The color object.
Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0. In PostScript, this color space corresponds directly to the device-dependent operator setrgbcolor.
+ colorWithCalibratedHue:saturation:brightness:alpha:+ colorWithDeviceRed:green:blue:alpha:– getHue:saturation:brightness:alpha:NSColor.hCreates and returns an NSColor object using the given opacity value and RGB components.
+ (NSColor *)colorWithDeviceRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha
The red component of the color object.
The green component of the color object.
The blue component of the color object.
The opacity value of the color object.
The color object.
Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0. In PostScript, this color space corresponds directly to the device-dependent operator setrgbcolor.
+ colorWithCalibratedRed:green:blue:alpha:+ colorWithDeviceHue:saturation:brightness:alpha:– getRed:green:blue:alpha:NSColor.hCreates and returns an NSColor object using the given opacity and grayscale values.
+ (NSColor *)colorWithDeviceWhite:(CGFloat)white alpha:(CGFloat)alpha
The grayscale value of the color object.
The opacity value of the color object.
The color object.
Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0. In PostScript, this color space corresponds directly to the device-dependent operator setgray.
NSColor.h
Creates and returns an NSColor object that uses the specified image pattern.
+ (NSColor *)colorWithPatternImage:(NSImage *)image
The image to use as the pattern for the color object. The image is tiled starting at the bottom of the window. The image is not scaled.
The NSColor object. This color object is autoreleased.
NSColor.h
Returns an array containing the system specified background colors for alternating rows in tables and lists.
+ (NSArray *)controlAlternatingRowBackgroundColors
An array of NSColor objects specifying the system colors used for rows in tables and lists. You should not assume the array will contain only two colors. For general information on system colors, see “Accessing System Colors”.
NSColor.hReturns the system color used for the background of large controls.
+ (NSColor *)controlBackgroundColor
The system color used for the background of large controls such as browsers, table views, and clip views. For general information on system colors, see “Accessing System Colors”.
NSColor.h
Returns the system color used for the flat surfaces of a control.
+ (NSColor *)controlColor
The system color used for the flat surfaces of a control. By default, the control color is a pattern color that will draw the ruled lines for the window background, which is the same as returned by windowBackgroundColor.
If you use controlColor assuming that it is a solid, you may have an incorrect appearance. You should use lightGrayColor in its place.
NSColor.h
Returns the system color used for the dark edge of the shadow dropped from controls.
+ (NSColor *)controlDarkShadowColor
Of the two dark borders that run along the bottom and right of controls, representing shadows, the color of the outer, darker border. For general information about system colors, see “Accessing System Colors”.
NSColor.h
Returns the system color used for the highlighted bezels of controls.
+ (NSColor *)controlHighlightColor
Of the two light borders that run along the top and left of controls, representing reflections from a light source in the upper left, the color of the inner, duller border. For general information about system colors, see “Accessing System Colors”.
NSColor.h
Returns the system color used for light highlights in controls.
+ (NSColor *)controlLightHighlightColor
Of the two light borders that run along the top and left of controls, representing reflections from a light source in the upper left, the color of the outer, brighter border. For general information about system colors, see “Accessing System Colors”.
NSColor.h
Returns the system color used for the shadows dropped from controls.
+ (NSColor *)controlShadowColor
Of the two dark borders that run along the bottom and right of controls, representing shadows, the color of the inner, lighter border. For general information about system colors, see “Accessing System Colors”.
NSColor.h
Returns the system color used for text on controls that aren’t disabled.
+ (NSColor *)controlTextColor
The color used for text on enabled controls. For general information about system colors, see “Accessing System Colors”.
NSColor.h
Returns the current system control tint.
+ (NSControlTint)currentControlTint
The current system control tint.
An application can register for the NSControlTintDidChangeNotification notification to be notified of changes to the system control tint.
NSColor.h
Returns an NSColor object whose RGB value is 0.0, 1.0, 1.0 and whose alpha value is 1.0.
+ (NSColor *)cyanColor
The NSColor object.
NSColor.h
Returns an NSColor object whose grayscale value is 1/3 and whose alpha value is 1.0.
+ (NSColor *)darkGrayColor
The NSColor object.
NSColor.hReturns the system color used for text on disabled controls.
+ (NSColor *)disabledControlTextColor
The color used for text on disabled controls. For general information about system colors, see “Accessing System Colors”.
NSColor.h
Returns an NSColor object whose grayscale value is 0.5 and whose alpha value is 1.0.
+ (NSColor *)grayColor
The NSColor object.
NSColor.h
Returns an NSColor object whose RGB value is 0.0, 1.0, 0.0 and whose alpha value is 1.0.
+ (NSColor *)greenColor
The NSColor object.
NSColor.h
Returns the system color used for the optional gridlines in, for example, a table view.
+ (NSColor *)gridColor
The system color used for gridlines. For general information about system colors, see “Accessing System Colors”.
NSColor.h
Returns the system color used as the background color for header cells in table views and outline views.
+ (NSColor *)headerColor
The system color used as the background for header cells in table and outline views. For general information about system colors, see “Accessing System Colors”.
NSColor.h
Returns the system color used for text in header cells in table views and outline views.
+ (NSColor *)headerTextColor
The system color used for text in header cells in table and outline views. For general information about system colors, see “Accessing System Colors”.
NSColor.h
Returns the system color that represents the virtual light source on the screen.
+ (NSColor *)highlightColor
The system color for the virtual light source on the screen.
This method is invoked by the highlightWithLevel: method. For general information about system colors, see “Accessing System Colors”.
NSColor.h
Returns a Boolean value indicating whether the application supports alpha.
+ (BOOL)ignoresAlpha
YES if the application doesn't support alpha; otherwise NO. This value is consulted when an application imports alpha (through color dragging, for instance). The value determines whether the color panel has an opacity slider.
This value is YES by default, indicating that the opacity components of imported colors will be set to 1.0. If an application wants alpha, it can invoke the setIgnoresAlpha: method with a parameter of NO.
NSColor.hReturns the system color that represents the keyboard focus ring around controls.
+ (NSColor *)keyboardFocusIndicatorColor
The system color representing the focus ring.
NSColor.h
Returns the system color used for the flat surface of a slider knob that hasn’t been selected.
+ (NSColor *)knobColor
The system color used for an unselected slider knob.
The knob’s beveled edges, which set it in relief, are drawn in highlighted and shadowed versions of the face color. When a knob is selected, its color changes to selectedKnobColor. For general information about system colors, see “Accessing System Colors”.
NSColor.h
Returns an NSColor object whose grayscale value is 2/3 and whose alpha value is 1.0.
+ (NSColor *)lightGrayColor
The NSColor object.
NSColor.h
Returns an NSColor object whose RGB value is 1.0, 0.0, 1.0 and whose alpha value is 1.0.
+ (NSColor *)magentaColor
The NSColor object.
NSColor.h
Returns an NSColor object whose RGB value is 1.0, 0.5, 0.0 and whose alpha value is 1.0.
+ (NSColor *)orangeColor
The NSColor object.
NSColor.h