UIColor
public extension UIColor
An extension to test if colors meet standard accessibility contrast requirements.
-
A requirement defining how the visual presentation of text achieves a minimum contrast ratio to pass the accessibility specification - https://www.w3.org/TR/2008/REC-WCAG20-20081211/#visual-audio-contrast-contrast
See moreDeclaration
Swift
enum AccessibilityRequirement
-
Tests if two contrasting colors pass a provided accessibility requirement.
Declaration
Swift
static func isCompliant(with requirement: AccessibilityRequirement, testing foreground: UIColor, against background: UIColor) -> Bool
Parameters
requirement
The accessibility requirement to test.
foreground
The foreground color to contrast against the
background
color.background
The background color to contrast against the
foreground
color.Return Value
true
if the two contrasting colors pass the accessibility requirement. -
Tests if the current color, contrasting with another color, passes a provided accessibility requirement.
Declaration
Swift
func isCompliant(with requirement: AccessibilityRequirement, against background: UIColor) -> Bool
Parameters
requirement
The accessibility requirement to test.
background
The background color to contrast against the current color.
Return Value
true
if the two contrasting colors pass the accessibility requirement.
-
Returns the contrast ratio between two colors based on their luminance values.
Declaration
Swift
static func contrastRatio(between color1: UIColor, and color2: UIColor) -> CGFloat
Parameters
color1
The first color to compare to the second.
color2
The second color to compare to the first.
Return Value
The contrast ratio between the two colors.
-
Returns the contrast ratio of the color compared to another color based on their luminance values.
Declaration
Swift
func contrastRatio(to color: UIColor) -> CGFloat
Parameters
color
The other color to compare.
Return Value
The contrast ratio between the two colors.
-
Compares the contrast ratio of the color to two others and returns which of the two colors has the higher ratio.
Declaration
Swift
func higherContrastingColor(between color1: UIColor, and color2: UIColor) -> UIColor
Parameters
color1
The first color to compare to the base color.
color2
The second color to compare to the base color.
Return Value
The color with the higher contrast ratio compared to the base color.
-
Compares the contrast ratio of the color to an array of others and returns which color in the array has the highest ratio.
Declaration
Swift
func highestContrastingColor(between colors: [UIColor]) -> UIColor?
Parameters
colors
An array of colors to compare to the base color.
Return Value
The color with the highest contrast ratio compared to the base color.
-
Compares the contrast ratio of the color to two others and returns which of the two colors has the lower ratio.
Declaration
Swift
func lowerContrastingColor(between color1: UIColor, and color2: UIColor) -> UIColor
Parameters
color1
The first color to compare to the base color.
color2
The second color to compare to the base color.
Return Value
The color with the lower contrast ratio compared to the base color.
-
Compares the contrast ratio of the color to an array of others and returns which color in the array has the lowest ratio.
Declaration
Swift
func lowestContrastingColor(between colors: [UIColor]) -> UIColor?
Parameters
colors
An array of colors to compare to the base color.
Return Value
The color with the lowest contrast ratio compared to the base color.
-
The relative luminance of the color, measured according to the HSL color model.
Declaration
Swift
var relativeLuminance: CGFloat { get }
-
The perceived brightness of the color, measured according to the HSP color model - http://alienryderflex.com/hsp.html
Declaration
Swift
var perceivedBrightness: CGFloat { get }
-
Returns
true
if the color is considered light according to its perceived brightness.Declaration
Swift
var isLight: Bool { get }
-
Returns
true
if the color is considered dark according to its perceived brightness.Declaration
Swift
var isDark: Bool { get }
-
Returns a new instance of the color with an adjusted hue.
Declaration
Swift
func adjustingHue(by degrees: CGFloat) -> UIColor
Parameters
degrees
The amount to adjust the hue, in the range [-360°, 360°].
Return Value
The hue adjusted color.
-
The color opposite on the color wheel, equivalant to adjusting the hue by 180°.
Declaration
Swift
var complement: UIColor { get }
-
Returns
true
if the color falls on the cool side of the color wheel (90° ≤ hue < 270°).Declaration
Swift
var isCool: Bool { get }
-
Returns
true
if the color falls on the warm side of the color wheel (90° > hue ≥ 270°).Declaration
Swift
var isWarm: Bool { get }
-
The negative of the color, produced by inverting the RGB values.
Declaration
Swift
var inverted: UIColor { get }
-
Returns a new instance of the color with increased lightness.
Declaration
Swift
func lighter(percent: CGFloat = 0.1) -> UIColor
Parameters
percent
The amount to lighten the color, in the range [0, 1].
Return Value
The lighter color.
-
Returns a new instance of the color with decreased lightness.
Declaration
Swift
func darker(percent: CGFloat = 0.1) -> UIColor
Parameters
percent
The amount to darken the color, in the range [0, 1].
Return Value
The darker color.
-
Returns a new instance of the color with increased saturation.
Declaration
Swift
func saturated(percent: CGFloat = 0.1) -> UIColor
Parameters
percent
The amount to saturate the color, in the range [0, 1].
Return Value
The saturated color.
-
Returns a new instance of the color with decreased saturation.
Declaration
Swift
func desaturated(percent: CGFloat = 0.1) -> UIColor
Parameters
percent
The amount to desaturate the color, in the range [0, 1].
Return Value
The desaturated color.
-
Returns a new instance of the color with 0% saturation.
Declaration
Swift
func grayscaled() -> UIColor
Return Value
The grayscaled color.
-
Returns the average color of an array of colors.
This function accounts for human visual perception by squaring the RGB values first, then dividing by the number of colors and taking the square root. Here is a video that explains it further: https://www.youtube.com/watch?v=LKnqECcg6Gw.
Declaration
Swift
static func average(of colors: [UIColor]) -> UIColor
Parameters
colors
The array of colors to average.
Return Value
The average color.
-
Returns the average of two colors.
This function accounts for human visual perception by squaring the RGB values first, then dividing by two and taking the square root. Here is a video that explains it further: https://www.youtube.com/watch?v=LKnqECcg6Gw.
Declaration
Swift
static func average(of color1: UIColor, and color2: UIColor) -> UIColor
Parameters
color1
The first color to average with the second.
color2
The second color to average with the first.
Return Value
The average color.
-
The nearest web safe color to the current color. All web safe colors have RGB component values of 0, 51, 102, 153, 204, or 255 (20% intervals).
Declaration
Swift
var webSafe: UIColor { get }
-
A color object whose RGB values are 0.0, 0.5, and 1.0 and whose alpha value is 1.0.
Declaration
Swift
open class var azure: UIColor { get }
-
A color object whose RGB values are 0.5, 0.0, and 1.0 and whose alpha value is 1.0.
Declaration
Swift
open class var violet: UIColor { get }
-
A color object whose RGB values are 1.0, 0.0, and 0.5 and whose alpha value is 1.0.
Declaration
Swift
open class var rose: UIColor { get }
-
A color object whose RGB values are 0.5, 1.0, and 0.0 and whose alpha value is 1.0.
Declaration
Swift
open class var chartreuse: UIColor { get }
-
A color object whose RGB values are 0.0, 1.0, and 0.5 and whose alpha value is 1.0.
Declaration
Swift
open class var springGreen: UIColor { get }
-
The colors that define the color wheel.
See moreDeclaration
Swift
struct ColorWheel
-
Generates an array of colors between a start and end color. The colors are produced by mixing the start color with the end color with evenly distributed stops.
Declaration
Swift
static func gradient(between start: UIColor, and end: UIColor, stops: Int = 5) -> [UIColor]
Parameters
start
The starting color of the gradient.
end
The ending color of the gradient.
stops
The number of colors to be produced, including the start and end. For example, 5 stops would return the following:
[start, 25%, 50%, 75%, end]
Return Value
The array of colors forming the gradient.
-
Generates an array of colors between a start and end color. The colors are produced by mixing the start color with the end color with a custom array of distributed stops. This function can be used to generate a gradient that is not evenly distributed.
Declaration
Swift
static func gradient(between start: UIColor, and end: UIColor, customStops: [CGFloat]) -> [UIColor]
Parameters
start
The color at a stop of
0%
.end
The color at a stop of
100%
.customStops
The array of custom stop percentages. The start and end color are not included by default; therefore, a value of
0.0
and1.0
should be included in the array, if desired.Return Value
The array of colors forming the gradient.
-
Returns a mixture of two colors with a given weight.
Declaration
Swift
static func mixing(_ first: UIColor, with second: UIColor, weight: CGFloat = 0.5) -> UIColor
Parameters
first
The first color to be mixed with the second color.
second
The second color to be mixed with the first color.
weight
The ratio of the second color mixed with the first color. The default value of 0.5 indicates 50% of each color is mixed together. A value of 0.25 indicates 25% of the second color is mixed with 75% of the first color.
Return Value
The mixed color.
-
Returns a mixture of the source color with another color.
Declaration
Swift
func mixed(with color: UIColor, weight: CGFloat = 0.5) -> UIColor
Parameters
color
The other color to be mixed with the source color.
weight
The ratio of the second color (other) mixed with the first color (source). The default value of 0.5 indicates 50% of each color is mixed together. A value of 0.25 indicates 25% of the second color is mixed with 75% of the first color.
Return Value
The mixed color.
-
A model that describes how colors are mixed together to form all other colors.
See moreDeclaration
Swift
enum MixingModel
-
Returns a mixture of the color with black, decreasing lightness.
Declaration
Swift
func shade(percent: CGFloat = 0.1) -> UIColor
Parameters
percent
The amount of black mixed with the color, in the range [0, 1].
Return Value
The shaded color after mixing with black.
-
Returns a mixture of the color with white, increasing lightness.
Declaration
Swift
func tint(percent: CGFloat = 0.1) -> UIColor
Parameters
percent
The amount of white mixed with the color, in the range [0, 1].
Return Value
The tinted color after mixing with white.
-
Returns a mixture of the color with gray, decreasing saturation.
Declaration
Swift
func tone(percent: CGFloat = 0.1) -> UIColor
Parameters
percent
The amount of gray mixed with the color, in the range [0, 1].
Return Value
The toned color after mixing with gray.
-
Returns a color with random component values.
Declaration
Swift
static func random(includeAlpha: Bool = false) -> UIColor
Parameters
includeAlpha
Indicates whether the alpha component should be randomized. If
false
, the color will have an alpha value of1.0
.Return Value
The random color.
-
Returns a set of unique colors with random component values.
Declaration
Swift
static func randomSet(of amount: Int, includeAlpha: Bool = false) -> Set<UIColor>
Parameters
amount
The amount of random colors to be generated.
includeAlpha
Indicates whether the alpha components should be randomized. If
false
, the colors will have an alpha value of1.0
.Return Value
The random set of colors.
-
The ARGB (alpha, red, green, blue) components of a color, in the range [0, 255].
See moreDeclaration
Swift
struct ARGB : Hashable
-
The ARGB (alpha, red, green, blue) components of the color, in the range [0, 255].
Declaration
Swift
var argb: ARGB { get }
-
Initializes a color from ARGB (alpha, red, green, blue) components.
Declaration
Swift
convenience init(_ argb: ARGB)
Parameters
argb
The components used to initialize the color.
-
The CIELAB components of a color - lightness (L) and chromaticity (a,b).
See moreDeclaration
Swift
struct CIELAB : Hashable
-
The CIELAB components of the color using a d65 illuminant and 2° standard observer.
Declaration
Swift
var Lab: CIELAB { get }
-
The CIELAB components of the color using a given illuminant and standard observer.
Declaration
Swift
func Lab(illuminant: Illuminant, observer: StandardObserver) -> CIELAB
Parameters
illuminant
The illuminant used to calculate tristimulus values.
observer
The standard observer used to calculate tristimulus values.
Return Value
The CIELAB components of the color.
-
Initializes a color from CIELAB components.
Declaration
Swift
convenience init(_ Lab: CIELAB, illuminant: Illuminant = .d65, observer: StandardObserver = .two, alpha: CGFloat = 1.0)
Parameters
Lab
The components used to initialize the color.
illuminant
The illuminant used to calculate tristimulus values.
observer
The standard observer used calculate tristimulus values.
alpha
The alpha value of the color.
-
The CIELCh° components of a color - lightness (L), chroma ©, and hue (h).
See moreDeclaration
Swift
struct CIELCh : Hashable
-
The CIELCh°(ab) components of the color using a d65 illuminant and 2° standard observer.
Declaration
Swift
var LCh_ab: CIELCh { get }
-
The CIELCh°(ab) components of the color using a given illuminant and standard observer.
Declaration
Swift
func LCh_ab(illuminant: Illuminant, observer: StandardObserver) -> CIELCh
Parameters
illuminant
The illuminant used to calculate tristimulus values.
observer
The standard observer used to calculate tristimulus values.
Return Value
The CIELCh°(ab) components of the color.
-
Initializes a color from CIELCh°(ab) components.
Declaration
Swift
convenience init(ab LCh: CIELCh, illuminant: Illuminant = .d65, observer: StandardObserver = .two, alpha: CGFloat = 1.0)
Parameters
LCh
The components used to initialize the color.
illuminant
The illuminant used to calculate tristimulus values.
observer
The standard observer used calculate tristimulus values.
alpha
The alpha value of the color.
-
The CIELCh°(uv) components of the color using a d65 illuminant and 2° standard observer.
Declaration
Swift
var LCh_uv: CIELCh { get }
-
The CIELCh°(uv) components of the color using a given illuminant and standard observer.
Declaration
Swift
func LCh_uv(illuminant: Illuminant, observer: StandardObserver) -> CIELCh
Parameters
illuminant
The illuminant used to calculate tristimulus values.
observer
The standard observer used to calculate tristimulus values.
Return Value
The CIELCh°(uv) components of the color.
-
Initializes a color from CIELCh°(uv) components.
Declaration
Swift
convenience init(uv LCh: CIELCh, illuminant: Illuminant = .d65, observer: StandardObserver = .two, alpha: CGFloat = 1.0)
Parameters
LCh
The components used to initialize the color.
illuminant
The illuminant used to calculate tristimulus values.
observer
The standard observer used calculate tristimulus values.
alpha
The alpha value of the color.
-
The CIELUV components of a color - lightness (L) and chromaticity (u,v).
See moreDeclaration
Swift
struct CIELUV : Hashable
-
The CIELUV components of the color using a d65 illuminant and 2° standard observer.
Declaration
Swift
var Luv: CIELUV { get }
-
The CIELUV components of the color using a given illuminant and standard observer.
Declaration
Swift
func Luv(illuminant: Illuminant, observer: StandardObserver) -> CIELUV
Parameters
illuminant
The illuminant used to calculate tristimulus values.
observer
The standard observer used to calculate tristimulus values.
Return Value
The CIELUV components of the color.
-
Initializes a color from CIELUV components.
Declaration
Swift
convenience init(_ Luv: CIELUV, illuminant: Illuminant = .d65, observer: StandardObserver = .two, alpha: CGFloat = 1.0)
Parameters
Luv
The components used to initialize the color.
illuminant
The illuminant used to calculate tristimulus values.
observer
The standard observer used calculate tristimulus values.
alpha
The alpha value of the color.
-
The CIE 1960 UCS components of a color - (u,v) chromaticity coordinates.
See moreDeclaration
Swift
struct CIEUCS : Hashable
-
The CIE 1960 UCS components of the color.
Declaration
Swift
var ucs: CIEUCS { get }
-
Initializes a color from CIE 1960 UCS components.
Declaration
Swift
convenience init(_ ucs: CIEUCS, luminance: CGFloat = 1.0, alpha: CGFloat = 1.0)
Parameters
ucs
The components used to initialize the color.
luminance
The luminance value of the color.
alpha
The alpha value of the color.
-
The CIE 1964 UVW components of a color - chromaticity (U,V) and lightness (W).
See moreDeclaration
Swift
struct CIEUVW : Hashable
-
The CIE 1964 UVW components of the color using a d65 illuminant and 2° standard observer.
Declaration
Swift
var uvw: CIEUVW { get }
-
The CIE 1964 UVW components of the color using a given illuminant and standard observer.
Declaration
Swift
func uvw(illuminant: Illuminant, observer: StandardObserver) -> CIEUVW
Parameters
illuminant
The illuminant used to calculate tristimulus values.
observer
The standard observer used to calculate tristimulus values.
Return Value
The CIE 1964 UVW components of the color.
-
Initializes a color from CIE 1964 UVW components.
Declaration
Swift
convenience init(_ uvw: CIEUVW, illuminant: Illuminant = .d65, observer: StandardObserver = .two, alpha: CGFloat = 1.0)
Parameters
uvw
The components used to initialize the color.
illuminant
The illuminant used to calculate tristimulus values.
observer
The standard observer used calculate tristimulus values.
alpha
The alpha value of the color.
-
The CIE xyY components of a color - luminance (Y) and chromaticity (x,y).
See moreDeclaration
Swift
struct CIExyY : Hashable
-
The CIE xyY components of the color.
Declaration
Swift
var xyY: CIExyY { get }
-
Initializes a color from CIE xyY components.
Declaration
Swift
convenience init(_ xyY: CIExyY, alpha: CGFloat = 1.0)
Parameters
xyY
The components used to initialize the color.
alpha
The alpha value of the color.
-
The CMYK (cyan, magenta, yellow, black) components of a color, in the range [0, 100%].
See moreDeclaration
Swift
struct CMYK : Hashable
-
The CMYK (cyan, magenta, yellow, black) components of the color, in the range [0, 100%].
Declaration
Swift
var cmyk: CMYK { get }
-
Initializes a color from CMYK (cyan, magenta, yellow, black) components.
Declaration
Swift
convenience init(_ cmyk: CMYK, alpha: CGFloat = 1.0)
Parameters
cmyk
The components used to initialize the color.
alpha
The alpha value of the color.
-
The HSB (hue, saturation, brightness) components of a color.
See moreDeclaration
Swift
struct HSB : Hashable
-
The HSB (hue, saturation, brightness) components of the color.
Declaration
Swift
var hsb: HSB { get }
-
Initializes a color from HSB (hue, saturation, brightness) components.
Declaration
Swift
convenience init(_ hsb: HSB, alpha: CGFloat = 1.0)
Parameters
hsb
The components used to initialize the color.
alpha
The alpha value of the color.
-
The HSI (hue, saturation, intensity) components of a color.
See moreDeclaration
Swift
struct HSI : Hashable
-
The HSI (hue, saturation, intensity) components of the color.
Declaration
Swift
var hsi: HSI { get }
-
Initializes a color from HSI (hue, saturation, intensity) components.
Declaration
Swift
convenience init(_ hsi: HSI, alpha: CGFloat = 1.0)
Parameters
hsi
The components used to initialize the color.
alpha
The alpha value of the color.
-
The HSL (hue, saturation, lightness) components of a color.
See moreDeclaration
Swift
struct HSL : Hashable
-
The HSL (hue, saturation, lightness) components of the color.
Declaration
Swift
var hsl: HSL { get }
-
Initializes a color from HSL (hue, saturation, lightness) components.
Declaration
Swift
convenience init(_ hsl: HSL, alpha: CGFloat = 1.0)
Parameters
hsl
The components used to initialize the color.
alpha
The alpha value of the color.
-
The HSV (hue, saturation, value) components of a color.
See moreDeclaration
Swift
struct HSV : Hashable
-
The HSV (hue, saturation, value) components of the color.
Declaration
Swift
var hsv: HSV { get }
-
Initializes a color from HSV (hue, saturation, value) components.
Declaration
Swift
convenience init(_ hsv: HSV, alpha: CGFloat = 1.0)
Parameters
hsv
The components used to initialize the color.
alpha
The alpha value of the color.
-
Initializes a color from a hexadecimal integer in the RGB format (RRGGBB), e.g., 0xffff00.
Declaration
Swift
convenience init(hex: Int, alpha: CGFloat = 1.0)
Parameters
hex
The hexadecimal value of the color.
alpha
The alpha value of the color.
-
Initializes a color from a hexadecimal string in the RGB format (RRGGBB), e.g., “#ffff00”.
Declaration
Swift
convenience init?(hex: String, alpha: CGFloat = 1.0)
Parameters
hex
The hexadecimal string value of the color.
alpha
The alpha value of the color.
-
The hexadecimal integer value of the color in the RGB format (RRGGBB), e.g., 0xffff00.
Declaration
Swift
var hex: Int { get }
-
The hexadecimal string value of the color in the RGB format (RRGGBB), e.g., “#ffff00”.
Declaration
Swift
var hexString: String { get }
-
Initializes a color from a hexadecimal integer in the ARGB format (AARRGGBB), e.g., 0x80ffff00.
Declaration
Swift
convenience init(hex_ARGB hex: Int)
Parameters
hex
The hexadecimal value of the color.
-
Initializes a color from a hexadecimal string in the ARGB format (AARRGGBB), e.g., “#80ffff00”.
Declaration
Swift
convenience init?(hex_ARGB hex: String)
Parameters
hex
The hexadecimal string value of the color.
-
The hexadecimal integer value of the color in the ARGB format (AARRGGBB), e.g., 0x80ffff00.
Declaration
Swift
var hex_ARGB: Int { get }
-
The hexadecimal string value of the color in the ARGB format (AARRGGBB), e.g., “#80ffff00”.
Declaration
Swift
var hexString_ARGB: String { get }
-
Initializes a color from a hexadecimal integer in the RGBA format (RRGGBBAA), e.g., 0xffff0080.
Declaration
Swift
convenience init(hex_RGBA hex: Int)
Parameters
hex
The hexadecimal value of the color.
-
Initializes a color from a hexadecimal string in the RGBA format (RRGGBBAA), e.g., “#ffff0080”.
Declaration
Swift
convenience init?(hex_RGBA hex: String)
Parameters
hex
The hexadecimal string value of the color.
-
The hexadecimal integer value of the color in the RGBA format (RRGGBBAA), e.g., 0xffff0080.
Declaration
Swift
var hex_RGBA: Int { get }
-
The hexadecimal string value of the color in the RGBA format (RRGGBBAA), e.g., “#ffff0080”.
Declaration
Swift
var hexString_RGBA: String { get }
-
The Hunter Lab components of a color - lightness (L) and chromaticity (a,b).
See moreDeclaration
Swift
struct HunterLab : Hashable
-
The Hunter Lab components of the color using a d65 illuminant and 2° standard observer.
Declaration
Swift
var hunterLab: HunterLab { get }
-
The Hunter Lab components of the color using a given illuminant and standard observer.
Declaration
Swift
func hunterLab(illuminant: Illuminant, observer: StandardObserver) -> HunterLab
Parameters
illuminant
The illuminant used to calculate tristimulus values.
observer
The standard observer used to calculate tristimulus values.
Return Value
The Hunter Lab components of the color.
-
Initializes a color from Hunter Lab components.
Declaration
Swift
convenience init(_ hunterLab: HunterLab, illuminant: Illuminant = .d65, observer: StandardObserver = .two, alpha: CGFloat = 1.0)
Parameters
hunterLab
The components used to initialize the color.
illuminant
The illuminant used to calculate tristimulus values.
observer
The standard observer used calculate tristimulus values.
alpha
The alpha value of the color.
-
A set of non-gamma corrected linear RGB values, in the range [0, 1].
Declaration
Swift
typealias LinearRGB = (r: CGFloat, g: CGFloat, b: CGFloat)
-
The inverse companded sRGB components to get non-gamma corrected linear values, in the range [0, 1].
Declaration
Swift
var linearRGB: LinearRGB { get }
-
Initializes an sRGB gamma corrected color from linear RGB values.
Declaration
Swift
convenience init(linear rgb: LinearRGB, alpha: CGFloat = 1.0)
Parameters
rgb
The linear RGB values to be gamma corrected.
alpha
The alpha value of the color.
-
The RGB (red, green, blue) components of a color, in the range [0, 255].
See moreDeclaration
Swift
struct RGB : Hashable
-
The RGB (red, green, blue) components of the color, in the range [0, 255].
Declaration
Swift
var rgb: RGB { get }
-
Initializes a color from RGB (red, green, blue) components.
Declaration
Swift
convenience init(_ rgb: RGB, alpha: CGFloat = 1.0)
Parameters
rgb
The components used to initialize the color.
alpha
The alpha value of the color.
-
The RGBA (red, green, blue, alpha) components of a color, in the range [0, 255].
See moreDeclaration
Swift
struct RGBA : Hashable
-
The RGBA (red, green, blue, alpha) components of a color, in the range [0, 255].
Declaration
Swift
var rgba: RGBA { get }
-
Initializes a color from RGBA (red, green, blue, alpha) components.
Declaration
Swift
convenience init(_ rgba: RGBA)
Parameters
rgba
The components used to initialize the color.
-
The Y′CbCr components of a color - luma (Y′) and chroma (Cb,Cr).
See moreDeclaration
Swift
struct YCbCr : Hashable
-
The Y′CbCr components of the color using Rec.601 (standard-definition) encoding.
Declaration
Swift
var yCbCr: YCbCr { get }
-
The Y′CbCr components of the color using a given encoding.
Declaration
Swift
func yCbCr(_ encoding: SignalEncoding) -> YCbCr
Parameters
encoding
The signal encoding with which the components are derived.
Return Value
The Y′CbCr components of the color.
-
Initializes a color from Y′CbCr components.
Declaration
Swift
convenience init(_ yCbCr: YCbCr, encoding: SignalEncoding = .rec601, alpha: CGFloat = 1.0)
Parameters
yCbCr
The components used to initialize the color.
encoding
The signal encoding with which the components were derived.
alpha
The alpha value of the color.
-
The Y′IQ components of a color - luma (Y′) and chroma (I,Q).
See moreDeclaration
Swift
struct YIQ : Hashable
-
The Y′IQ components of the color using Rec.601 (standard-definition) encoding.
Declaration
Swift
var yiq: YIQ { get }
-
The Y′IQ components of the color using a given encoding.
Declaration
Swift
func yiq(_ encoding: SignalEncoding) -> YIQ
Parameters
encoding
The signal encoding with which the components are derived.
Return Value
The Y′IQ components of the color.
-
Initializes a color from Y′IQ components.
Declaration
Swift
convenience init(_ yiq: YIQ, encoding: SignalEncoding = .rec601, alpha: CGFloat = 1.0)
Parameters
yiq
The components used to initialize the color.
encoding
The signal encoding with which the components were derived.
alpha
The alpha value of the color.
-
The Y′PbPr components of a color - luma (Y′) and chroma (Pb,Pr).
See moreDeclaration
Swift
struct YPbPr : Hashable
-
The Y′PbPr components of the color using Rec.601 (standard-definition) encoding.
Declaration
Swift
var yPbPr: YPbPr { get }
-
The Y′PbPr components of the color using a given encoding.
Declaration
Swift
func yPbPr(_ encoding: SignalEncoding) -> YPbPr
Parameters
encoding
The signal encoding with which the components are derived.
Return Value
The Y′PbPr components of the color.
-
Initializes a color from Y′PbPr components.
Declaration
Swift
convenience init(_ yPbPr: YPbPr, encoding: SignalEncoding = .rec601, alpha: CGFloat = 1.0)
Parameters
yPbPr
The components used to initialize the color.
encoding
The signal encoding with which the components were derived.
alpha
The alpha value of the color.
-
The Y′UV components of a color - luma (Y′) and chroma (U,V).
See moreDeclaration
Swift
struct YUV : Hashable
-
The Y′UV components of the color using Rec.601 (standard-definition) encoding.
Declaration
Swift
var yuv: YUV { get }
-
The Y′UV components of the color using a given encoding.
Declaration
Swift
func yuv(_ encoding: SignalEncoding) -> YUV
Parameters
encoding
The signal encoding with which the components are derived.
Return Value
The Y′UV components of the color.
-
Initializes a color from Y′UV components.
Declaration
Swift
convenience init(_ yuv: YUV, encoding: SignalEncoding = .rec601, alpha: CGFloat = 1.0)
Parameters
yuv
The components used to initialize the color.
encoding
The signal encoding with which the components were derived.
alpha
The alpha value of the color.
-
A color model is an abstract mathematical model describing the ways colors can be represented as tuples of numbers, typically as three or four values or color components.
See moreDeclaration
Swift
enum ColorModel
-
A color space is a specific organization of colors. In combination with physical device profiling, it allows for reproducible representations of color, in both analog and digital representations. Adding a specific mapping function between a color model and a reference color space establishes a definite “footprint”, known as a gamut, and for a given color model this defines a color space.
See moreDeclaration
Swift
enum ColorSpace
-
The red component of the color, in the range [0, 1].
Declaration
Swift
var redComponent: CGFloat { get }
-
The green component of the color, in the range [0, 1].
Declaration
Swift
var greenComponent: CGFloat { get }
-
The blue component of the color, in the range [0, 1].
Declaration
Swift
var blueComponent: CGFloat { get }
-
The alpha component of the color, in the range [0, 1].
Declaration
Swift
var alphaComponent: CGFloat { get }
-
The red, green, and blue components of the color, in the range [0, 1].
Declaration
Swift
var rgbComponents: (r: CGFloat, g: CGFloat, b: CGFloat) { get }
-
The red, green, blue, and alpha components of the color, in the range [0, 1].
Declaration
Swift
var rgbaComponents: (r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat) { get }
-
The alpha, red, green, and blue components of the color, in the range [0, 1].
Declaration
Swift
var argbComponents: (a: CGFloat, r: CGFloat, g: CGFloat, b: CGFloat) { get }
-
Initializes a color from a tuple of RGB components.
Declaration
Swift
convenience init(rgb: (r: CGFloat, g: CGFloat, b: CGFloat), alpha: CGFloat = 1.0)
Parameters
rgb
The components used to initialize the color.
alpha
The alpha value of the color.
-
Initializes a color from a tuple of RGBA components.
Declaration
Swift
convenience init(rgba: (r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat))
Parameters
rgba
The components used to initialize the color.
alpha
The alpha value of the color.
-
Initializes a color from a tuple of ARGB components.
Declaration
Swift
convenience init(argb: (a: CGFloat, r: CGFloat, g: CGFloat, b: CGFloat))
Parameters
argb
The components used to initialize the color.
alpha
The alpha value of the color.
-
The hue component of the color, in the range [0, 1].
Declaration
Swift
var hueComponent: CGFloat { get }
-
The saturation component of the color, in the range [0, 1].
Declaration
Swift
var saturationComponent: CGFloat { get }
-
The brightness component of the color, in the range [0, 1].
Declaration
Swift
var brightnessComponent: CGFloat { get }
-
The hue, saturation, and brightness components of the color, in the range [0, 1].
Declaration
Swift
var hsbComponents: (h: CGFloat, s: CGFloat, b: CGFloat) { get }
-
Initializes a color from a tuple of HSB components.
Declaration
Swift
convenience init(hsb: (h: CGFloat, s: CGFloat, b: CGFloat), alpha: CGFloat = 1.0)
Parameters
hsb
The components used to initialize the color.
alpha
The alpha value of the color.
-
The white component of the color, in the range [0, 1].
Declaration
Swift
var whiteComponent: CGFloat { get }
-
A standard illuminant defined by the International Commission on Illumination (CIE) which provides a basis for comparing images or colors recorded under different lighting.
See moreDeclaration
Swift
enum Illuminant
-
A CIE color-mapping function called the standard observer which represents an average human’s chromatic response while observing an object under an illuminant.
See moreDeclaration
Swift
enum StandardObserver
-
The Pantone colors of the year color palette.
Pantone is a limited liability company best known for its Pantone Matching System (PMS), a proprietary color space used in a variety of industries, notably printing, and some manufacturing of colored paint, fabric, and plastics.
See moreDeclaration
Swift
struct Pantone
-
A standard ITU-R Recommendation signal encoding.
ITU-R Recommendations are the names given to the set of international technical standards developed by the Radiocommunication Sector of the International Telecommunication Union (ITU).
See moreDeclaration
Swift
enum SignalEncoding
-
Tristimulus system, a system for visually matching a color under standardized conditions against the three primary colors — red, green, and blue; the three results are expressed as X, Y, and Z, respectively, and are called tristimulus values.
Declaration
Swift
typealias Tristimulus = UIColor.CIEXYZ