init(colorsSpace:colors:locations:)
Creates a gradient object from a color space and the provided color objects and locations.
Declaration
init?(colorsSpace space: CGColorSpace?, colors: CFArray, locations: UnsafePointer<CGFloat>?)Parameters
- space:
The color space to use for the gradient. You cannot use a pattern or indexed color space.
- colors:
A non-empty array of Cgcolor objects that should be in the color space specified by
space. Ifspaceis notNULL, each color will be converted (if necessary) to that color space and the gradient will drawn in that color space. Otherwise, each color will be converted to and drawn in the GenericRGB color space. - locations:
The location for each color provided in
colors; each location must be a Cgfloat Swift.struct value in the range of0to1, inclusive. If0and1are not in thelocationsarray, Quartz uses the colors provided that are closest to0and1for those locations.If
locationsisNULL, the first color incolorsis assigned to location0, the last color incolorsis assigned to location1, and intervening colors are assigned locations that are at equal intervals in between.The
locationsarray should contain the same number of items as thecolorsarray.
Return Value
A CGGradient object.
See Also
Related Documentation
drawRadialGradient(_:startCenter:startRadius:endCenter:endRadius:options:)drawLinearGradient(_:start:end:options:)