Initializer

init(named:in:compatibleWith:)

Creates a color object using the named asset that is compatible with the specified trait collection.

Declaration

init?(named name: String, in bundle: Bundle?, compatibleWith traitCollection: UITraitCollection?)

Parameters

name

The name of the asset containing the color.

bundle

The bundle containing the asset.

traitCollection

The trait collection that specifies the gamut to use when selecting the color.

Return Value

An initialized color object. The returned object uses the color space specified for the asset.

See Also

Creating a Color from Component Values

init(white: CGFloat, alpha: CGFloat)

Creates a color object using the specified opacity and grayscale values.

init(hue: CGFloat, saturation: CGFloat, brightness: CGFloat, alpha: CGFloat)

Creates a color object using the specified opacity and HSB color space component values.

init(red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat)

Creates a color object using the specified opacity and RGB component values.

init(displayP3Red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat)

Creates a color object using the specified opacity and RGB component values in the Display P3 color space.

init?(named: String)

Creates a color object using the information stored in the named asset.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software