Mac Developer Library

Developer

AppKit Framework Reference NSColor Class Reference

Options
Deployment Target:

On This Page
Language:

NSColor

Inheritance


Import Statement


Swift

import AppKit

Objective-C

@import AppKit;

Availability


Available in OS X v10.0 and later.

Class at a Glance

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.

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, the redComponent property and getRed:green:blue:alpha: method 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. Further, the getComponents: method and numberOfComponents property work in color spaces that have individual components. Thus they return the components of NSColor objects as individual floating-point values regardless of whether they’re based on NSColorSpace objects or named color spaces. However, older component-fetching methods such as getRed:green:blue:alpha: are only effective on NSColor objects based on named color spaces.

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.

  • Creates and returns an NSColor object using the given opacity and HSB color space components.

    Declaration

    Swift

    init(calibratedHue hue: CGFloat, saturation saturation: CGFloat, brightness brightness: CGFloat, alpha alpha: CGFloat) -> NSColor

    Objective-C

    + (NSColor *)colorWithCalibratedHue:(CGFloat)hue saturation:(CGFloat)saturation brightness:(CGFloat)brightness alpha:(CGFloat)alpha

    Parameters

    hue

    The hue component of the color object in the HSB color space.

    saturation

    The saturation component of the color object in the HSB color space.

    brightness

    The brightness (or value) component of the color object in the HSB color space.

    alpha

    The opacity value of the color object,

    Return Value

    The color object.

    Discussion

    Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Creates and returns an NSColor object using the given opacity and RGB components.

    Declaration

    Swift

    init(calibratedRed red: CGFloat, green green: CGFloat, blue blue: CGFloat, alpha alpha: CGFloat) -> NSColor

    Objective-C

    + (NSColor *)colorWithCalibratedRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha

    Parameters

    red

    The red component of the color object.

    green

    The green component of the color object.

    blue

    The blue component of the color object.

    alpha

    The opacity value of the color object.

    Return Value

    The color object.

    Discussion

    Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Creates and returns an NSColor object using the given opacity and grayscale value.

    Declaration

    Swift

    init(calibratedWhite white: CGFloat, alpha alpha: CGFloat) -> NSColor

    Objective-C

    + (NSColor *)colorWithCalibratedWhite:(CGFloat)white alpha:(CGFloat)alpha

    Parameters

    white

    The grayscale value of the color object.

    alpha

    The opacity value of the color object.

    Return Value

    The color object.

    Discussion

    Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Creates and returns an NSColor object by finding the color with the specified name in the given catalog.

    Declaration

    Swift

    init?(catalogName listName: String, colorName colorName: String) -> NSColor

    Objective-C

    + (NSColor *)colorWithCatalogName:(NSString *)listName colorName:(NSString *)colorName

    Parameters

    listName

    The name of the catalog in which to find the specified color; this may be a standard catalog.

    colorName

    The name of the color. Note that the color must be defined in the named color space to retrieve it with this method.

    Return Value

    The color object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Creates and returns an NSColor object using the given opacity value and CMYK components.

    Declaration

    Swift

    init(deviceCyan cyan: CGFloat, magenta magenta: CGFloat, yellow yellow: CGFloat, black black: CGFloat, alpha alpha: CGFloat) -> NSColor

    Objective-C

    + (NSColor *)colorWithDeviceCyan:(CGFloat)cyan magenta:(CGFloat)magenta yellow:(CGFloat)yellow black:(CGFloat)black alpha:(CGFloat)alpha

    Parameters

    cyan

    The cyan component of the color object.

    magenta

    The magenta component of the color object.

    yellow

    The yellow component of the color object.

    black

    The black component of the color object.

    alpha

    The opacity value of the color object.

    Return Value

    The color object.

    Discussion

    Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Creates and returns an NSColor object using the given opacity value and HSB color space components.

    Declaration

    Swift

    init(deviceHue hue: CGFloat, saturation saturation: CGFloat, brightness brightness: CGFloat, alpha alpha: CGFloat) -> NSColor

    Objective-C

    + (NSColor *)colorWithDeviceHue:(CGFloat)hue saturation:(CGFloat)saturation brightness:(CGFloat)brightness alpha:(CGFloat)alpha

    Parameters

    hue

    The hue component of the color object.

    saturation

    The saturation component of the color object.

    brightness

    The brightness component of the color object.

    alpha

    The opacity value of the color object.

    Return Value

    The color object.

    Discussion

    Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Creates and returns an NSColor object using the given opacity value and RGB components.

    Declaration

    Swift

    init(deviceRed red: CGFloat, green green: CGFloat, blue blue: CGFloat, alpha alpha: CGFloat) -> NSColor

    Objective-C

    + (NSColor *)colorWithDeviceRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha

    Parameters

    red

    The red component of the color object.

    green

    The green component of the color object.

    blue

    The blue component of the color object.

    alpha

    The opacity value of the color object.

    Return Value

    The color object.

    Discussion

    Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Creates and returns an NSColor object using the given opacity and grayscale values.

    Declaration

    Swift

    init(deviceWhite white: CGFloat, alpha alpha: CGFloat) -> NSColor

    Objective-C

    + (NSColor *)colorWithDeviceWhite:(CGFloat)white alpha:(CGFloat)alpha

    Parameters

    white

    The grayscale value of the color object.

    alpha

    The opacity value of the color object.

    Return Value

    The color object.

    Discussion

    Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Converts a Core Image color object to its NSColor equivalent.

    Declaration

    Swift

    init(CIColor color: CIColor) -> NSColor

    Objective-C

    + (NSColor *)colorWithCIColor:(CIColor *)color

    Parameters

    color

    The Core Image color to convert.

    Return Value

    The NSColor object corresponding to the specified Core Image color.

    Discussion

    The method raises if the color space and components associated with color are nil or invalid.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns an NSColor object created from the specified components of the given color space.

    Declaration

    Swift

    init(colorSpace space: NSColorSpace, components components: UnsafePointer<CGFloat>, count numberOfComponents: Int) -> NSColor

    Objective-C

    + (NSColor *)colorWithColorSpace:(NSColorSpace *)space components:(const CGFloat *)components count:(NSInteger)numberOfComponents

    Parameters

    space

    An NSColorSpace object representing a color space. The method raises if this is nil.

    components

    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.)

    numberOfComponents

    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.

    Return Value

    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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Returns a color created from the specified components in the sRGB colorspace.

    Declaration

    Swift

    init(SRGBRed red: CGFloat, green green: CGFloat, blue blue: CGFloat, alpha alpha: CGFloat) -> NSColor

    Objective-C

    + (NSColor *)colorWithSRGBRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha

    Parameters

    red

    The red component of the color object.

    green

    The green component of the color object.

    blue

    The blue component of the color object.

    alpha

    The opacity value of the color object.

    Return Value

    The color object.

    Discussion

    Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • Returns an color created with the specified white and alpha values in the GenericGamma22 colorspace.

    Declaration

    Swift

    init(genericGamma22White white: CGFloat, alpha alpha: CGFloat) -> NSColor

    Objective-C

    + (NSColor *)colorWithGenericGamma22White:(CGFloat)white alpha:(CGFloat)alpha

    Parameters

    white

    The white value of the color object.

    alpha

    The opacity value of the color object.

    Return Value

    The color object.

    Discussion

    Values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.7 and later.

  • Creates and returns an NSColor object with the specified hue, saturation, brightness, and alpha channel values.

    Declaration

    Swift

    init(hue hue: CGFloat, saturation saturation: CGFloat, brightness brightness: CGFloat, alpha alpha: CGFloat) -> NSColor

    Objective-C

    + (NSColor *)colorWithHue:(CGFloat)hue saturation:(CGFloat)saturation brightness:(CGFloat)brightness alpha:(CGFloat)alpha

    Parameters

    hue

    The hue (color) component, expressed as a floating-point value in the range 0–1.0.

    saturation

    The color saturation component, expressed as a floating-point value in the range 0–1.0.

    brightness

    The brightness component, expressed as a floating-point value in the range 0–1.0.

    alpha

    The alpha (opacity), expressed as a floating-point value in the range 0 (transparent) to 1.0 (opaque).

    Discussion

    This method creates an NSCustomColorSpace color that is compatible with the sRGB colorspace. This method is provided for easier reuse of code that uses UIColor on iOS.

    Where possible, it is preferable to specify the colorspace explicitly using the colorWithSRGBRed:green:blue:alpha: or colorWithGenericGamma22White:alpha: method.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Creates and returns an NSColor object with the specified red, green, blue, and alpha channel values.

    Declaration

    Swift

    init(red red: CGFloat, green green: CGFloat, blue blue: CGFloat, alpha alpha: CGFloat) -> NSColor

    Objective-C

    + (NSColor *)colorWithRed:(CGFloat)red green:(CGFloat)green blue:(CGFloat)blue alpha:(CGFloat)alpha

    Parameters

    red

    The red channel value, expressed as a floating-point value in the range 0–1.0.

    green

    The green channel value, expressed as a floating-point value in the range 0–1.0.

    blue

    The blue channel value, expressed as a floating-point value in the range 0–1.0.

    alpha

    The alpha (opacity), expressed as a floating-point value in the range 0 (transparent) to 1.0 (opaque).

    Discussion

    This method creates an NSCustomColorSpace color that is compatible with the sRGB colorspace. This method is provided for easier reuse of code that uses UIColor on iOS.

    Where possible, it is preferable to specify the colorspace explicitly using the colorWithSRGBRed:green:blue:alpha: or colorWithGenericGamma22White:alpha: method.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Creates and returns a white (or grey) NSColor object with the specified brightness and alpha channel values.

    Declaration

    Swift

    init(white white: CGFloat, alpha alpha: CGFloat) -> NSColor

    Objective-C

    + (NSColor *)colorWithWhite:(CGFloat)white alpha:(CGFloat)alpha

    Parameters

    white

    The brightness, expressed as a floating-point value in the range 0–1.0.

    alpha

    The alpha (opacity), expressed as a floating-point value in the range 0 (transparent) to 1.0 (opaque).

    Discussion

    This method creates an NSCustomColorSpace color that is compatible with the sRGB colorspace. This method is provided for easier reuse of code that uses UIColor on iOS.

    Where possible, it is preferable to specify the colorspace explicitly using the colorWithSRGBRed:green:blue:alpha: or colorWithGenericGamma22White:alpha: method.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.9 and later.

  • Returns an NSColor object whose grayscale value is 0.0 and whose alpha value is 1.0.

    Declaration

    Swift

    class func blackColor() -> NSColor

    Objective-C

    + (NSColor *)blackColor

    Return Value

    The NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    blackComponent

  • Returns an NSColor object whose RGB value is 0.0, 0.0, 1.0 and whose alpha value is 1.0.

    Declaration

    Swift

    class func blueColor() -> NSColor

    Objective-C

    + (NSColor *)blueColor

    Return Value

    The NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    blueComponent

  • Returns an NSColor object whose RGB value is 0.6, 0.4, 0.2 and whose alpha value is 1.0.

    Declaration

    Swift

    class func brownColor() -> NSColor

    Objective-C

    + (NSColor *)brownColor

    Return Value

    The NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns an NSColor object whose grayscale and alpha values are both 0.0.

    Declaration

    Swift

    class func clearColor() -> NSColor

    Objective-C

    + (NSColor *)clearColor

    Return Value

    The NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns an NSColor object whose RGB value is 0.0, 1.0, 1.0 and whose alpha value is 1.0.

    Declaration

    Swift

    class func cyanColor() -> NSColor

    Objective-C

    + (NSColor *)cyanColor

    Return Value

    The NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    cyanComponent

  • Returns an NSColor object whose grayscale value is 1/3 and whose alpha value is 1.0.

    Declaration

    Swift

    class func darkGrayColor() -> NSColor

    Objective-C

    + (NSColor *)darkGrayColor

    Return Value

    The NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns an NSColor object whose grayscale value is 0.5 and whose alpha value is 1.0.

    Declaration

    Swift

    class func grayColor() -> NSColor

    Objective-C

    + (NSColor *)grayColor

    Return Value

    The NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns an NSColor object whose RGB value is 0.0, 1.0, 0.0 and whose alpha value is 1.0.

    Declaration

    Swift

    class func greenColor() -> NSColor

    Objective-C

    + (NSColor *)greenColor

    Return Value

    The NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    greenComponent

  • Returns an NSColor object whose grayscale value is 2/3 and whose alpha value is 1.0.

    Declaration

    Swift

    class func lightGrayColor() -> NSColor

    Objective-C

    + (NSColor *)lightGrayColor

    Return Value

    The NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns an NSColor object whose RGB value is 1.0, 0.0, 1.0 and whose alpha value is 1.0.

    Declaration

    Swift

    class func magentaColor() -> NSColor

    Objective-C

    + (NSColor *)magentaColor

    Return Value

    The NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    magentaComponent

  • Returns an NSColor object whose RGB value is 1.0, 0.5, 0.0 and whose alpha value is 1.0.

    Declaration

    Swift

    class func orangeColor() -> NSColor

    Objective-C

    + (NSColor *)orangeColor

    Return Value

    The NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns an NSColor object whose RGB value is 0.5, 0.0, 0.5 and whose alpha value is 1.0.

    Declaration

    Swift

    class func purpleColor() -> NSColor

    Objective-C

    + (NSColor *)purpleColor

    Return Value

    The NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns an NSColor object whose RGB value is 1.0, 0.0, 0.0 and whose alpha value is 1.0.

    Declaration

    Swift

    class func redColor() -> NSColor

    Objective-C

    + (NSColor *)redColor

    Return Value

    The NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    redComponent

  • Returns an NSColor object whose grayscale and alpha values are both 1.0.

    Declaration

    Swift

    class func whiteColor() -> NSColor

    Objective-C

    + (NSColor *)whiteColor

    Return Value

    The NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    whiteComponent

  • Returns an NSColor object whose RGB value is 1.0, 1.0, 0.0 and whose alpha value is 1.0.

    Declaration

    Swift

    class func yellowColor() -> NSColor

    Objective-C

    + (NSColor *)yellowColor

    Return Value

    The NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    yellowComponent

  • Creates and returns an NSColor object that uses the specified image pattern.

    Declaration

    Swift

    init(patternImage image: NSImage) -> NSColor

    Objective-C

    + (NSColor *)colorWithPatternImage:(NSImage *)image

    Parameters

    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.

    Return Value

    The NSColor object. This color object is autoreleased.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • The pattern image used as a color. (read-only)

    Declaration

    Swift

    var patternImage: NSImage { get }

    Objective-C

    @property(readonly, strong) NSImage *patternImage

    Discussion

    This property contains the image (instead of the solid color) to use during drawing. Pattern images are tiled as needed to fill the rendered area.

    Do not access this property unless you created the color object using a pattern image. Accessing this property for colors created using other types of color information raises an exception.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for the face of a selected control in a list or table.

    Declaration

    Swift

    class func alternateSelectedControlColor() -> NSColor

    Objective-C

    + (NSColor *)alternateSelectedControlColor

    Return Value

    The system color used for the face of a selected control—a control being clicked or dragged. This color is used in lists and tables. For general information about system colors, see Accessing System Colors.

    Discussion

    This color is the table and list view equivalent to the selectedControlColor color, which is used for controls in other views.

    For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.2 and later.

  • Returns the system color used for text in a selected control.

    Declaration

    Swift

    class func alternateSelectedControlTextColor() -> NSColor

    Objective-C

    + (NSColor *)alternateSelectedControlTextColor

    Discussion

    This color is the table and list view equivalent to the selectedControlTextColor color, which is used for controls in other views.

    For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.2 and later.

  • Returns the NSColor object specified by the given control tint.

    Declaration

    Swift

    init(forControlTint controlTint: NSControlTint) -> NSColor

    Objective-C

    + (NSColor *)colorForControlTint:(NSControlTint)controlTint

    Parameters

    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.

    Return Value

    The NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for the background of large controls.

    Declaration

    Swift

    class func controlBackgroundColor() -> NSColor

    Objective-C

    + (NSColor *)controlBackgroundColor

    Return Value

    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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for the flat surfaces of a control.

    Declaration

    Swift

    class func controlColor() -> NSColor

    Objective-C

    + (NSColor *)controlColor

    Return Value

    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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns an array containing the system specified background colors for alternating rows in tables and lists.

    Declaration

    Swift

    class func controlAlternatingRowBackgroundColors() -> [AnyObject]

    Objective-C

    + (NSArray *)controlAlternatingRowBackgroundColors

    Return Value

    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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Returns the system color used for the highlighted bezels of controls.

    Declaration

    Swift

    class func controlHighlightColor() -> NSColor

    Objective-C

    + (NSColor *)controlHighlightColor

    Return Value

    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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for light highlights in controls.

    Declaration

    Swift

    class func controlLightHighlightColor() -> NSColor

    Objective-C

    + (NSColor *)controlLightHighlightColor

    Return Value

    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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for the shadows dropped from controls.

    Declaration

    Swift

    class func controlShadowColor() -> NSColor

    Objective-C

    + (NSColor *)controlShadowColor

    Return Value

    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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for the dark edge of the shadow dropped from controls.

    Declaration

    Swift

    class func controlDarkShadowColor() -> NSColor

    Objective-C

    + (NSColor *)controlDarkShadowColor

    Return Value

    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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for text on controls that aren’t disabled.

    Declaration

    Swift

    class func controlTextColor() -> NSColor

    Objective-C

    + (NSColor *)controlTextColor

    Return Value

    The color used for text on enabled controls. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the current system control tint.

    Declaration

    Swift

    class func currentControlTint() -> NSControlTint

    Objective-C

    + (NSControlTint)currentControlTint

    Return Value

    The current system control tint.

    Discussion

    An application can register for the NSControlTintDidChangeNotification notification to be notified of changes to the system control tint.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

  • Returns the system color used for text on disabled controls.

    Declaration

    Swift

    class func disabledControlTextColor() -> NSColor

    Objective-C

    + (NSColor *)disabledControlTextColor

    Return Value

    The color used for text on disabled controls. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for the optional gridlines in, for example, a table view.

    Declaration

    Swift

    class func gridColor() -> NSColor

    Objective-C

    + (NSColor *)gridColor

    Return Value

    The system color used for gridlines. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used as the background color for header cells in table views and outline views.

    Declaration

    Swift

    class func headerColor() -> NSColor

    Objective-C

    + (NSColor *)headerColor

    Return Value

    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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for text in header cells in table views and outline views.

    Declaration

    Swift

    class func headerTextColor() -> NSColor

    Objective-C

    + (NSColor *)headerTextColor

    Return Value

    The system color used for text in header cells in table and outline views. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color that represents the virtual light source on the screen.

    Declaration

    Swift

    class func highlightColor() -> NSColor

    Objective-C

    + (NSColor *)highlightColor

    Return Value

    The system color for the virtual light source on the screen.

    Discussion

    This method is invoked by the highlightWithLevel: method. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color that represents the keyboard focus ring around controls.

    Declaration

    Swift

    class func keyboardFocusIndicatorColor() -> NSColor

    Objective-C

    + (NSColor *)keyboardFocusIndicatorColor

    Return Value

    The system color representing the focus ring.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for the flat surface of a slider knob that hasn’t been selected.

    Declaration

    Swift

    class func knobColor() -> NSColor

    Objective-C

    + (NSColor *)knobColor

    Return Value

    The system color used for an unselected slider knob.

    Discussion

    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.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for scroll “bars”—that is, for the groove in which a scroller’s knob moves

    Declaration

    Swift

    class func scrollBarColor() -> NSColor

    Objective-C

    + (NSColor *)scrollBarColor

    Return Value

    The system color used for scroll bars. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the color used for selected controls in non-key views.

    Declaration

    Swift

    class func secondarySelectedControlColor() -> NSColor

    Objective-C

    + (NSColor *)secondarySelectedControlColor

    Return Value

    The system color used for selected controls in non-key views. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.1 and later.

  • Returns the system color used for the face of a selected control—a control that has been clicked or is being dragged.

    Declaration

    Swift

    class func selectedControlColor() -> NSColor

    Objective-C

    + (NSColor *)selectedControlColor

    Discussion

    For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for text in a selected control—a control being clicked or dragged.

    Declaration

    Swift

    class func selectedControlTextColor() -> NSColor

    Objective-C

    + (NSColor *)selectedControlTextColor

    Discussion

    For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for the face of selected menu items.

    Declaration

    Swift

    class func selectedMenuItemColor() -> NSColor

    Objective-C

    + (NSColor *)selectedMenuItemColor

    Return Value

    The system color used for selected menu items. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for the text in menu items.

    Declaration

    Swift

    class func selectedMenuItemTextColor() -> NSColor

    Objective-C

    + (NSColor *)selectedMenuItemTextColor

    Return Value

    The system color used for text in selected menu items. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for the background of selected text.

    Declaration

    Swift

    class func selectedTextBackgroundColor() -> NSColor

    Objective-C

    + (NSColor *)selectedTextBackgroundColor

    Return Value

    The system color used for the background of selected text. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for selected text.

    Declaration

    Swift

    class func selectedTextColor() -> NSColor

    Objective-C

    + (NSColor *)selectedTextColor

    Return Value

    The system color used for selected text. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for the slider knob when it is selected.

    Declaration

    Swift

    class func selectedKnobColor() -> NSColor

    Objective-C

    + (NSColor *)selectedKnobColor

    Return Value

    The system color used for a slider knob that is selected—that is, dragged. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    + knobColor

  • Returns the system color that represents the virtual shadows cast by raised objects on the screen.

    Declaration

    Swift

    class func shadowColor() -> NSColor

    Objective-C

    + (NSColor *)shadowColor

    Return Value

    The system color for the virtual shadows case by raised objects on the screen.

    Discussion

    This method is invoked by shadowWithLevel:. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for the text background.

    Declaration

    Swift

    class func textBackgroundColor() -> NSColor

    Objective-C

    + (NSColor *)textBackgroundColor

    Return Value

    The system color used for the background of text. When text is selected, its background color changes to the return value of selectedTextBackgroundColor. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    + textColor

  • Returns the system color used for text.

    Declaration

    Swift

    class func textColor() -> NSColor

    Objective-C

    + (NSColor *)textColor

    Return Value

    The system color used for text. When text is selected, its color changes to the return value of selectedTextColor. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns a pattern color that will draw the ruled lines for the window background.

    Declaration

    Swift

    class func windowBackgroundColor() -> NSColor

    Objective-C

    + (NSColor *)windowBackgroundColor

    Return Value

    The pattern color used for the background of a window. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for window frames, except for their text.

    Declaration

    Swift

    class func windowFrameColor() -> NSColor

    Objective-C

    + (NSColor *)windowFrameColor

    Return Value

    The system color used for window frames. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the system color used for the text in window frames.

    Declaration

    Swift

    class func windowFrameTextColor() -> NSColor

    Objective-C

    + (NSColor *)windowFrameTextColor

    Return Value

    The system color used for text in window frames. For general information about system colors, see Accessing System Colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the color to use when areas revealed behind views.

    Declaration

    Swift

    class func underPageBackgroundColor() -> NSColor

    Objective-C

    + (NSColor *)underPageBackgroundColor

    Return Value

    An NSColor instance.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.8 and later.

  • The primary color to use for text in labels.

    Declaration

    Swift

    class func labelColor() -> NSColor

    Objective-C

    + (NSColor *)labelColor

    Return Value

    A color object to use for text displayed in your interface.

    Discussion

    Use this color in the most important text labels of your user interface.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

  • The secondary color to use for text in labels.

    Declaration

    Swift

    class func secondaryLabelColor() -> NSColor

    Objective-C

    + (NSColor *)secondaryLabelColor

    Return Value

    A color object to use for text displayed in your interface.

    Discussion

    Use this color in text fields that contain less important text in your user interface. For example, you might use this in labels that display subheads or additional information.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

  • The tertiary color to use for text in labels.

    Declaration

    Swift

    class func tertiaryLabelColor() -> NSColor

    Objective-C

    + (NSColor *)tertiaryLabelColor

    Return Value

    A color object to use for text displayed in your interface.

    Discussion

    Use this color for disabled text and for other less important text in your interface.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

  • The quaternary color to use for label text and separators

    Declaration

    Swift

    class func quaternaryLabelColor() -> NSColor

    Objective-C

    + (NSColor *)quaternaryLabelColor

    Return Value

    A color object to use for text displayed in your interface.

    Discussion

    Use this color for the least important text in your interface and for separators between text items. For example, you would use this color for secondary text that is disabled.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.10 and later.

  • Returns a Boolean value indicating whether the application supports alpha.

    Declaration

    Swift

    class func ignoresAlpha() -> Bool

    Objective-C

    + (BOOL)ignoresAlpha

    Return Value

    YEStrue if the application doesn't support alpha; otherwise NOfalse. 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 YEStrue 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 NOfalse.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Specifies whether an application supports alpha.

    Declaration

    Swift

    class func setIgnoresAlpha(_ flag: Bool)

    Objective-C

    + (void)setIgnoresAlpha:(BOOL)flag

    Parameters

    flag

    YEStrue to indicate that the application won’t support alpha. By default, applications ignore alpha.

    Discussion

    If the application doesn't support alpha, no opacity slider is displayed in the color panel, and colors dragged in or pasted have their alpha values set to 1.0. Applications that need to import alpha can invoke this method with flag set to NOfalse and explicitly make colors opaque in cases where it matters to them. Note that calling this with a value of YEStrue overrides any value set with the NSColorPanel method setShowsAlpha:.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the NSColor currently on the given pasteboard.

    Declaration

    Swift

    init?(fromPasteboard pasteBoard: NSPasteboard) -> NSColor

    Objective-C

    + (NSColor *)colorFromPasteboard:(NSPasteboard *)pasteBoard

    Parameters

    pasteBoard

    The pasteboard from which to return the color.

    Return Value

    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 YEStrue.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Writes the receiver’s data to the specified pasteboard.

    Declaration

    Swift

    func writeToPasteboard(_ pasteBoard: NSPasteboard)

    Objective-C

    - (void)writeToPasteboard:(NSPasteboard *)pasteBoard

    Parameters

    pasteBoard

    The pasteboard to which to write the receiver's color data. If this pasteboard doesn’t support color data, the method does nothing.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the receiver’s CMYK and opacity values.

    Declaration

    Swift

    func getCyan(_ cyan: UnsafeMutablePointer<CGFloat>, magenta magenta: UnsafeMutablePointer<CGFloat>, yellow yellow: UnsafeMutablePointer<CGFloat>, black black: UnsafeMutablePointer<CGFloat>, alpha alpha: UnsafeMutablePointer<CGFloat>)

    Objective-C

    - (void)getCyan:(CGFloat *)cyan magenta:(CGFloat *)magenta yellow:(CGFloat *)yellow black:(CGFloat *)black alpha:(CGFloat *)alpha

    Parameters

    cyan

    Upon return, contains the cyan component of the color object.

    magenta

    Upon return, contains the magenta component of the color object.

    yellow

    Upon return, contains the yellow component of the color object.

    black

    Upon return, contains the black component of the color object.

    alpha

    Upon return, contains opacity value of the color object.

    Discussion

    If NULL is passed in as an argument, the method doesn’t set that value. This method works only with objects representing colors in the NSDeviceCMYKColorSpace. Sending it to other objects raises an exception.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the receiver’s HSB component and opacity values in the respective arguments.

    Declaration

    Swift

    func getHue(_ hue: UnsafeMutablePointer<CGFloat>, saturation saturation: UnsafeMutablePointer<CGFloat>, brightness brightness: UnsafeMutablePointer<CGFloat>, alpha alpha: UnsafeMutablePointer<CGFloat>)

    Objective-C

    - (void)getHue:(CGFloat *)hue saturation:(CGFloat *)saturation brightness:(CGFloat *)brightness alpha:(CGFloat *)alpha

    Parameters

    hue

    Upon return, contains the hue component of the color object.

    saturation

    Upon return, contains the saturation component of the color object.

    brightness

    Upon return, contains the brightness component of the color object.

    alpha

    Upon return, contains the opacity value of the color object.

    Discussion

    If NULL is passed in as an argument, the method doesn’t set that value. This method works only with objects representing colors in the NSCalibratedRGBColorSpace or NSDeviceRGBColorSpace color space. Sending it to other objects raises an exception.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the receiver’s RGB component and opacity values in the respective arguments.

    Declaration

    Swift

    func getRed(_ red: UnsafeMutablePointer<CGFloat>, green green: UnsafeMutablePointer<CGFloat>, blue blue: UnsafeMutablePointer<CGFloat>, alpha alpha: UnsafeMutablePointer<CGFloat>)

    Objective-C

    - (void)getRed:(CGFloat *)red green:(CGFloat *)green blue:(CGFloat *)blue alpha:(CGFloat *)alpha

    Parameters

    red

    Upon return, contains the red component of the color object.

    green

    Upon return, contains the green component of the color object.

    blue

    Upon return, contains the blue component of the color object.

    alpha

    Upon return, contains the opacity value of the color object.

    Discussion

    If NULL is passed in as an argument, the method doesn’t set that value. This method works only with objects representing colors in the NSCalibratedRGBColorSpace or NSDeviceRGBColorSpace color space. Sending it to other objects raises an exception.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the receiver’s grayscale value and alpha values.

    Declaration

    Swift

    func getWhite(_ white: UnsafeMutablePointer<CGFloat>, alpha alpha: UnsafeMutablePointer<CGFloat>)

    Objective-C

    - (void)getWhite:(CGFloat *)white alpha:(CGFloat *)alpha

    Parameters

    white

    Upon return, contains the grayscale value of the color object.

    alpha

    Upon return, contains the opacity value of the color object.

    Discussion

    If NULL is passed in as an argument, the method doesn’t set that value. This method works only with objects representing colors in the NSCalibratedWhiteColorSpace, NSCalibratedBlackColorSpace, NSDeviceBlackColorSpace, or NSDeviceWhiteColorSpace color space. Sending it to other objects raises an exception.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns the components of the receiver as an array.

    Declaration

    Swift

    func getComponents(_ components: UnsafeMutablePointer<CGFloat>)

    Objective-C

    - (void)getComponents:(CGFloat *)components

    Parameters

    components

    An array containing the components of the color object as float values.

    Discussion

    You can invoke this method on NSColor objects created from custom color spaces to get the individual floating-point components, including alpha. Raises an exception if the receiver doesn’t have floating-point components. To find out how many components are in the components array, use the numberOfComponents property.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

    See Also

    colorSpace

  • The number of components in the color. (read-only)

    Declaration

    Swift

    var numberOfComponents: Int { get }

    Objective-C

    @property(readonly) NSInteger numberOfComponents

    Discussion

    This property reflects the number of floating-point component values in the color and includes the alpha component. If the color object does not have any floating-point component values, accessing this property raises an exception.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • The color space associated with the color. (read-only)

    Declaration

    Swift

    var colorSpace: NSColorSpace { get }

    Objective-C

    @property(readonly, strong) NSColorSpace *colorSpace

    Discussion

    Access this property only for colors that have an associated color space—specifically, colors not created by name or using a pattern image. Accessing it for other color types raises an exception. If you are unsure about a color object, convert it to an equivalent NSColorSpace-based object before calling this method.

    It is safe to access this property for color objects created with the color space names NSCalibratedWhiteColorSpace, NSCalibratedBlackColorSpace, NSCalibratedRGBColorSpace, NSDeviceWhiteColorSpace, NSDeviceBlackColorSpace, NSDeviceRGBColorSpace, NSDeviceCMYKColorSpace, or NSCustomColorSpace—or with the NSColorSpace class methods corresponding to these names.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • The name of the color space associated with the color. (read-only)

    Declaration

    Swift

    var colorSpaceName: String { get }

    Objective-C

    @property(readonly, copy) NSString *colorSpaceName

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Creates and returns an NSColor whose color is the same as the receiver’s, except that the new NSColor is in the specified color space.

    Declaration

    Swift

    func colorUsingColorSpaceName(_ colorSpace: String) -> NSColor?

    Objective-C

    - (NSColor *)colorUsingColorSpaceName:(NSString *)colorSpace

    Parameters

    colorSpace

    The name of the color space containing the new NSColor object. If colorSpace is nil, the most appropriate color space is used.

    Return Value

    The new NSColor object or nil if the specified conversion cannot be done.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

    See Also

    colorSpaceName

  • Creates and returns an NSColor object whose color is the same as the receiver’s, except that the new NSColor is in the given color space and is specific to the given device.

    Declaration

    Swift

    func colorUsingColorSpaceName(_ colorSpace: String?, device deviceDescription: [NSObject : AnyObject]?) -> NSColor?

    Objective-C

    - (NSColor *)colorUsingColorSpaceName:(NSString *)colorSpace device:(NSDictionary *)deviceDescription

    Parameters

    colorSpace

    The name of the color space containing the new NSColor object. If colorSpace is nil, the most appropriate color space is used.

    deviceDescription

    The device description. Device descriptions can be obtained from windows, screens, and printers with the deviceDescription method.

    If deviceDescription is nil, the current device (as obtained from the currently lockFocus’ed view’s window or, if printing, the current printer) is used.

    Return Value

    The new NSColor object or nil if the specified conversion cannot be done.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns a new color object representing the color of the receiver in the specified color space.

    Declaration

    Swift

    func colorUsingColorSpace(_ space: NSColorSpace) -> NSColor?

    Objective-C

    - (NSColor *)colorUsingColorSpace:(NSColorSpace *)space

    Parameters

    space

    The color space of the new NSColor object.

    Return Value

    The new NSColor object. This method converts the receiver's color to an equivalent one in the new color space. Although the new color might have different component values, it looks the same as the original. Returns nil if conversion is not possible.

    If the receiver's color space is the same as that specified in space, this method returns the same NSColor object.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.4 and later.

  • Creates and returns an NSColor object whose component values are a weighted sum of the receiver’s and the specified color object's.

    Declaration

    Swift

    func blendedColorWithFraction(_ fraction: CGFloat, ofColor color: NSColor) -> NSColor?

    Objective-C

    - (NSColor *)blendedColorWithFraction:(CGFloat)fraction ofColor:(NSColor *)color

    Parameters

    fraction

    The amount of the color to blend with the receiver's color. The method converts color and a copy of the receiver to RGB, and then sets each component of the returned color to fraction of color’s value plus 1 – fraction of the receiver’s.

    color

    The color to blend with the receiver's color.

    Return Value

    The resulting color object or nil if the colors can’t be converted.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Creates and returns an NSColor object that has the same color space and component values as the receiver, but the specified alpha component.

    Declaration

    Swift

    func colorWithAlphaComponent(_ alpha: CGFloat) -> NSColor

    Objective-C

    - (NSColor *)colorWithAlphaComponent:(CGFloat)alpha

    Parameters

    alpha

    The opacity value of the new NSColor object.

    Return Value

    The new NSColor object. If the receiver’s color space doesn’t include an alpha component, the receiver is returned.

    Discussion

    A subclass with explicit opacity components should override this method to return a color with the specified alpha.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns a color object that represents a blend between the receiver and the highlight color returned by highlightColor.

    Declaration

    Swift

    func highlightWithLevel(_ highlightLevel: CGFloat) -> NSColor?

    Objective-C

    - (NSColor *)highlightWithLevel:(CGFloat)highlightLevel

    Parameters

    highlightLevel

    The amount of the highlight color that is blended with the receiver's color. This should be a number from 0.0 through 1.0. A highlightLevel below 0.0 is interpreted as 0.0; a highlightLevel above 1.0 is interpreted as 1.0.

    Return Value

    The new NSColor object. Returns nil if the colors can’t be converted.

    Discussion

    Invoke this method when you want to brighten the receiving NSColor for use in highlights.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Returns a color object that represents a blend between the receiver and the shadow color returned by shadowColor.

    Declaration

    Swift

    func shadowWithLevel(_ shadowLevel: CGFloat) -> NSColor?

    Objective-C

    - (NSColor *)shadowWithLevel:(CGFloat)shadowLevel

    Parameters

    shadowLevel

    The amount of the shadow color used for the blend. This should be a number from 0.0 through 1.0. A shadowLevel below 0.0 is interpreted as 0.0; a shadowLevel above 1.0 is interpreted as 1.0.

    Return Value

    The new NSColor object. Returns nil if the colors can’t be converted.

    Discussion

    Invoke this method when you want to darken the receiving NSColor for use in shadows.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • CGColor CGColor Property

    The Core Graphics color object corresponding to the color. (read-only)

    Declaration

    Swift

    var CGColor: CGColor { get }

    Objective-C

    @property(readonly) CGColorRef CGColor

    Discussion

    This property always contains a valid color, even though the value may be an approximation in some cases. There is no guaranteed round-trip color fidelity.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.8 and later.

  • Creates and returns a new color using the specified CGColor.

    Declaration

    Swift

    init?(CGColor cgColor: CGColor) -> NSColor

    Objective-C

    + (NSColor *)colorWithCGColor:(CGColorRef)cgColor

    Parameters

    cgColor

    The Core Graphics color reference.

    Return Value

    An NSColor instance.

    Discussion

    This method may return nil.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.8 and later.

  • Draws the current color in the given rectangle.

    Declaration

    Swift

    func drawSwatchInRect(_ rect: NSRect)

    Objective-C

    - (void)drawSwatchInRect:(NSRect)rect

    Parameters

    rect

    The rectangle in which to draw the color.

    Discussion

    Subclasses adorn the rectangle in some manner to indicate the type of color. This method is invoked by color wells, swatches, and other user interface objects that need to display colors.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the color of subsequent drawing to the color that the receiver represents.

    Declaration

    Swift

    func set()

    Objective-C

    - (void)set

    Discussion

    This method should be implemented in subclasses.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.

  • Sets the fill color of subsequent drawing to the receiver’s color.

    Declaration

    Swift

    func setFill()

    Objective-C

    - (void)setFill

    Discussion

    This method should be implemented in subclasses.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

    See Also

    – setStroke

  • Sets the stroke color of subsequent drawing to the receiver’s color.

    Declaration

    Swift

    func setStroke()

    Objective-C

    - (void)setStroke

    Discussion

    This method should be implemented in subclasses.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.3 and later.

    See Also

    – setFill

  • The version of the AppKit framework containing a specific bug fix.

    Declaration

    Swift

    var NSAppKitVersionNumberWithPatternColorLeakFix: Double { get }

    Objective-C

    #define NSAppKitVersionNumberWithPatternColorLeakFix 641.0

    Constants

    • NSAppKitVersionNumberWithPatternColorLeakFix

      NSAppKitVersionNumberWithPatternColorLeakFix

      The specific version of the AppKit framework that introduced the fix for correctly autoreleasing objects returned by the colorWithPatternImage: method. Developers should not need to use this constant unless they are writing applications for OS X v10.1 and earlier.

      Available in OS X v10.2 and later.

  • Sent when the system colors have been changed (such as through a system control panel interface).

    This notification contains no notification object and no userInfo dictionary.

    Import Statement

    Objective-C

    @import AppKit;

    Swift

    import AppKit

    Availability

    Available in OS X v10.0 and later.