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 Custom UIColor Object in a Specific Color Space

init(white: CGFloat, alpha: CGFloat)

Initializes and returns a color object using the specified opacity and grayscale values.

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

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

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

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

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

Initializes and returns 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.