HexColor
public struct HexColor : Hashable
extension HexColor: Equatable
extension HexColor: CustomStringConvertible
Undocumented
-
init(lightColor:darkColor: elevatedLightColor: elevatedDarkColor: contrastLightColor: contrastDarkColor: elevatedContrastLightColor: elevatedContrastDarkColor: ) Constructs a
HexColorby defining a pair of hex colors to match.lightand.darkbackground 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
lightColora hex color (RGB or RGBA) for
darkbackground color scheme, default is000000.darkColora hex color (RGB or RGBA) for
lightbackground color scheme, default isFFFFFF.elevatedLightColora hex color (RGB or RGBA) for
elevateduser interface in thedarkbackground color scheme, default is000000.elevatedDarkColora hex color (RGB or RGBA) for
elevateduser interface in thelightbackground color scheme, default isFFFFFF.contrastLightColora hex color (RGB or RGBA) for
contrastuser interface in thedarkbackground color scheme, default is000000.contrastDarkColora hex color (RGB or RGBA) for
contrastuser interface in thelightbackground color scheme, default isFFFFFF.elevatedContrastLightColora hex color (RGB or RGBA) for
elevatedandcontrastuser interface in thedarkbackground color scheme, default is000000.elevatedContrastDarkColora hex color (RGB or RGBA) for
elevatedandcontrastuser interface in thelightbackground color scheme, default isFFFFFF. -
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
hexStringspecifies 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) -> StringParameters
variantspecifies the color variant.
Return Value
the string value for corresponding
HexColorwith specific color variant. -
Returns the
ColorVariantthat 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) -> ColorVariantParameters
backgroundspecifies the background color scheme, default is
.device.interfacespecifies the user interface level, default is
.device.displayspecifies the display mode, default is
.normal.Return Value
the string value for corresponding
HexColorwith specific color variant.