init(colors:atLocations:colorSpace:)
Initializes a newly allocated gradient object with the specified colors, color locations, and color space.
Declaration
init?(colors colorArray: [NSColor], atLocations locations: UnsafePointer<CGFloat>?, colorSpace: NSColorSpace)Parameters
- colorArray:
An array of
NSColorobjects representing the colors in the gradient. - locations:
An array of
CGFloatvalues containing the location for each color in the gradient. Each value must be in the range 0.0 to 1.0. There must be the same number of locations as are colors in thecolorArrayparameter. - colorSpace:
The color space to use for the gradient.
Return Value
The initialized NSGradient object.
Discussion
This method is the designated initializer of NSGradient. The colors in the colorArray parameter are converted to the specified color space if they are not already in that color space.
Typically, at least one color should have a location of 0.0 and one should have a location of 1.0. If these locations are not specified, the color at the closest color stop is used to fill the gap.