Color model enum (support for rgb, hsl, hsb, cmyk, and hex)
Computed properties on UIColor for hsl, hsb, and cmyk components
Initializers on UIColor for hsl and cmyk
Default alpha argument to existing initializers
Updated
Lighten/darken color APIs
The previous APIs left much to be desired, as they used a color's HSB values to adjust the lightness of the color. This led to situations where a color would not be lightened (no matter what value was specified), as shown below:
The updated APIs now provide expected behavior, as shown below:
As shown above, there is also a new operator to make the API a bit more clear. While CGFloat values between 0.0 and 1.0 may still be used, the % operator may also be used to achieve the same behavior. Example: color.darken(by: 0.5) == color.darken(by: 50%)
Deprecated
lighterColorByPercentage and darkerColorByPercentage
Added
alpha
argument to existing initializersUpdated
%
operator may also be used to achieve the same behavior. Example:color.darken(by: 0.5) == color.darken(by: 50%)
Deprecated
lighterColorByPercentage
anddarkerColorByPercentage
RGBAComponents
(renamed torgba
)redComponent
(in favor ofrgba.r
)greenComponent
(in favor ofrgba.g
)blueComponent
(in favor ofrgba.b
)