Instance Method

initWithColorsAndLocations:

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

Declaration

- (instancetype)initWithColorsAndLocations:(NSColor *)firstColor, ...;

Parameters

firstColor

The first color in the gradient.

...

A comma-separated list of alternating NSColor objects and location arguments (specified as CGFloat values). The first value after firstColor must be a location. Each location value must be between 0.0 and 1.0. The list must be nil-terminated.

Return Value

The initialized NSGradient object.

Discussion

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.

See Also

Initialization

- initWithStartingColor:endingColor:

Initializes a newly allocated gradient object with two colors.

- initWithColors:

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

- initWithColors:atLocations:colorSpace:

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