Instance Method

initWithColors:

Initializes a newly allocated gradient object with an array of colors.

Declaration

- (instancetype)initWithColors:(NSArray<NSColor *> *)colorArray;

Parameters

colorArray

An array of NSColor objects representing the colors to use to initialize the gradient. There must be at least two colors in the array. The first color is placed at location 0.0 and the last at location 1.0. If there are more than two colors, the additional colors are placed at evenly spaced intervals between the first and last colors.

Return Value

The initialized NSGradient object.

See Also

Initialization

- initWithStartingColor:endingColor:

Initializes a newly allocated gradient object with two colors.

- initWithColorsAndLocations:

Initializes a newly allocated gradient object with a comma-separated list of arguments.

- initWithColors:atLocations:colorSpace:

Initializes a newly allocated gradient object with the specified colors, color locations, and color space.