UIColor

Undocumented

  • Create a color from HEX with alpha.

    Declaration

    Swift

    public convenience init(hex: Int, alpha: CGFloat = 1.0)

    Parameters

    hex

    HEX value.

    alpha

    Alpha value.

  • Create a color from a HEX string. It supports the following type:

    • #ARGB, ARGB if irstIsAlpha is true. #RGBA, RGBA if firstIsAlpha is false.
    • #ARGB.
    • #RRGGBB.
    • AARRGGBB, AARRGGBB if irstIsAlpha is true. #RRGGBBAA, RRGGBBAA if firstIsAlpha is false.

    Declaration

    Swift

    public convenience init(hex: String, alphaFirst: Bool = false)

    Parameters

    hexString

    HEX string.

    alphaFirst

    Set it to true if alpha value is the first in the HEX string. If alpha value is the last one, set it to false. Default is false.

  • A good contrasting color, it will be either black or white.

    Declaration

    Swift

    public func contrasting() -> UIColor

    Return Value

    Returns the color.

  • A complementary color that should look good.

    Declaration

    Swift

    public func complementary() -> UIColor?

    Return Value

    Returns the color.

  • Check if the color is in RGB format.

    Declaration

    Swift

    public func canProvideRGBComponents() -> Bool

    Return Value

    Returns if the color is in RGB format.

  • Create a random color.

    Declaration

    Swift

    public static func random(alpha: CGFloat = 1.0) -> UIColor

    Parameters

    alpha

    Alpha value.

    Return Value

    Returns the UIColor instance.

  • Create an UIColor from a given string. Example: blue or hex string.

    Declaration

    Swift

    public static func color(string color: String) -> UIColor

    Parameters

    color

    String with color.

    Return Value

    Returns the created UIColor.

  • Create an UIColor from a given string like blue or an hex string.

    Declaration

    Swift

    public convenience init(string color: String)

    Parameters

    color

    String with color.

  • Creates and returns a color object that has the same color space and component values as the given color, but has the specified alpha component.

    Declaration

    Swift

    public static func color(color: UIColor, alpha: CGFloat) -> UIColor

    Parameters

    color

    UIColor value.

    alpha

    Alpha value.

    Return Value

    Returns an UIColor instance.