HexColor
public struct HexColor : Hashable
extension HexColor: Equatable
extension HexColor: CustomStringConvertible
Undocumented
-
init(lightColor:
darkColor: elevatedLightColor: elevatedDarkColor: contrastLightColor: contrastDarkColor: elevatedContrastLightColor: elevatedContrastDarkColor: ) 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 is000000
.darkColor
a hex color (RGB or RGBA) for
light
background color scheme, default isFFFFFF
.elevatedLightColor
a hex color (RGB or RGBA) for
elevated
user interface in thedark
background color scheme, default is000000
.elevatedDarkColor
a hex color (RGB or RGBA) for
elevated
user interface in thelight
background color scheme, default isFFFFFF
.contrastLightColor
a hex color (RGB or RGBA) for
contrast
user interface in thedark
background color scheme, default is000000
.contrastDarkColor
a hex color (RGB or RGBA) for
contrast
user interface in thelight
background color scheme, default isFFFFFF
.elevatedContrastLightColor
a hex color (RGB or RGBA) for
elevated
andcontrast
user interface in thedark
background color scheme, default is000000
.elevatedContrastDarkColor
a hex color (RGB or RGBA) for
elevated
andcontrast
user interface in thelight
background 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
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.