HexColor

public struct HexColor : Hashable
extension HexColor: Equatable
extension HexColor: CustomStringConvertible

Undocumented

  • Constructs a HexColor by defining a pair of hex colors to match .light and .dark background color scheme.

    Declaration

    Swift

    public init(lightColor: String? = nil, darkColor: String? = nil, elevatedLightColor: String? = nil, elevatedDarkColor: String? = nil, contrastLightColor: String? = nil, contrastDarkColor: String? = nil, elevatedContrastLightColor: String? = nil, elevatedContrastDarkColor: String? = nil)

    Parameters

    lightColor

    a hex color (RGB or RGBA) for dark background color scheme, default is 000000.

    darkColor

    a hex color (RGB or RGBA) for light background color scheme, default is FFFFFF.

    elevatedLightColor

    a hex color (RGB or RGBA) for elevated user interface in the dark background color scheme, default is 000000.

    elevatedDarkColor

    a hex color (RGB or RGBA) for elevated user interface in the light background color scheme, default is FFFFFF.

    contrastLightColor

    a hex color (RGB or RGBA) for contrast user interface in the dark background color scheme, default is 000000.

    contrastDarkColor

    a hex color (RGB or RGBA) for contrast user interface in the light background color scheme, default is FFFFFF.

    elevatedContrastLightColor

    a hex color (RGB or RGBA) for elevated and contrast user interface in the dark background color scheme, default is 000000.

    elevatedContrastDarkColor

    a hex color (RGB or RGBA) for elevated and contrast user interface in the light background color scheme, default is FFFFFF.

  • Returns a RGBA values tuple that matches with the specified hex color string.

    Declaration

    Swift

    public func rgba(_ hexString: String) -> (r: Double, g: Double, b: Double, a: Double)

    Parameters

    hexString

    specifies the hex color string.

    Return Value

    a tuple of RGBA values for corresponding HexColor.

  • Returns the string value that matches with the specified color variant from HexColor.

    Declaration

    Swift

    public func hex(_ variant: ColorVariant) -> String

    Parameters

    variant

    specifies the color variant.

    Return Value

    the string value for corresponding HexColor with specific color variant.

  • Returns the ColorVariant that matches with the specified combination of background color scheme, user interface level and display mode settings.

    Declaration

    Swift

    public func getVariant(traits collection: UITraitCollection, background scheme: BackgroundColorScheme? = .device, interface level: InterfaceLevel? = .device, display mode: ColorDisplayMode? = .device) -> ColorVariant

    Parameters

    background

    specifies the background color scheme, default is .device.

    interface

    specifies the user interface level, default is .device.

    display

    specifies the display mode, default is .normal.

    Return Value

    the string value for corresponding HexColor with specific color variant.