UIColor

Undocumented

  • Initializes and returns a color object using RGB component values as Int and an optional opacity value. - parameter red: The red value of the color object. Red values below 0 are interpreted as 0, and values above 255 are interpreted as 255. - parameter green: The green value of the color object. Green values below 0 are interpreted as 0, and values above 255 are interpreted as 255. - parameter blue: The blue value of the color object. Blue values below 0 are interpreted as 0, and values above 255 are interpreted as 255. - parameter transparency: Optional opacity value of the color object, specified as a value from 0.0 to 1.0. Alpha values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0. It defaults to 1.0. - returns: The color object. - seealso: init(red:green:blue:alpha)

    Declaration

    Swift

    public convenience init(red: Int, green: Int, blue: Int, transparency: CGFloat = 1.0)

    Parameters

    red

    The red value of the color object. Red values below 0 are interpreted as 0, and values above 255 are interpreted as 255.

    green

    The green value of the color object. Green values below 0 are interpreted as 0, and values above 255 are interpreted as 255.

    blue

    The blue value of the color object. Blue values below 0 are interpreted as 0, and values above 255 are interpreted as 255.

    transparency

    Optional opacity value of the color object, specified as a value from 0.0 to 1.0. Alpha values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0. It defaults to 1.0.

    Return Value

    The color object.

  • Initializes and returns a color object using RGB component values as a hexadecimal Int and an optional opacity value. - parameter hex: Hexadecimal value for RGB (example: 0xFF0000). - parameter alpha: Optional opacity value of the color object, specified as a value from 0.0 to 1.0. Alpha values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0. It defaults to 1.0. - returns: The color object. - seealso: init?(hexString:alpha:)

    Declaration

    Swift

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

    Parameters

    hex

    Hexadecimal value for RGB (example: ).

    alpha

    Optional opacity value of the color object, specified as a value from 0.0 to 1.0. Alpha values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0. It defaults to 1.0.

    Return Value

    The color object.

  • Initializes and returns an optional color object using RGB component values as a hexadecimal String and an optional opacity value.

    It uses Scanner‘s scanHexInt32. If the scanning fails it returns a nil. - parameter hexString: Hexadecimal value for RGB (example: FF0000 or #FF0000) - parameter alpha: Optional opacity value of the color object, specified as a value from 0.0 to 1.0. Alpha values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0. It defaults to 1.0. - returns: The optional color object. - seealso: init(hex:alpha:)

    Declaration

    Swift

    public convenience init?(hexString: String, alpha: CGFloat = 1.0)

    Parameters

    hexString

    Hexadecimal value for RGB (example: or )

    alpha

    Optional opacity value of the color object, specified as a value from 0.0 to 1.0. Alpha values below 0.0 are interpreted as 0.0, and values above 1.0 are interpreted as 1.0. It defaults to 1.0.

    Return Value

    The optional color object.

  • Creates a darker color from the receiver by altering it’s brightness by a percent (using the HSBA color space). - parameter percent: The percentage for decreasing brightness. Values below 0 are interpreted as 0, and values above 100 are interpreted as 100. - returns: The darker color object. - seealso: lighten(_:) - seealso: lighter(than:) - seealso: darker(than:)

    Declaration

    Swift

    public func darken(_ percent: Int) -> UIColor

    Parameters

    percent

    The percentage for decreasing brightness. Values below 0 are interpreted as 0, and values above 100 are interpreted as 100.

    Return Value

    The darker color object.

  • Creates a lighter color from the receiver by altering it’s brightness by a percent (using the HSBA color space). - parameter percent: The percentage for increasing brightness. Values below 0 are interpreted as 0, and values above 100 are interpreted as 100. - returns: The lighter color object. - seealso: darken(_:) - seealso: lighter(than:) - seealso: darker(than:)

    Declaration

    Swift

    public func lighten(_ percent: Int) -> UIColor

    Parameters

    percent

    The percentage for increasing brightness. Values below 0 are interpreted as 0, and values above 100 are interpreted as 100.

    Return Value

    The lighter color object.

  • Returns a Boolean value that indicates whether a given color is lighter than the receiver (compering their brightness values - from HSBA color space) - parameter other: the other color to compare to - returns: true if other is lighter, otherwise false - seealso: darker(than:) - seealso: darken(_:) - seealso: lighten(_:)

    Declaration

    Swift

    public func lighter(than other: UIColor) -> Bool

    Parameters

    other

    the other color to compare to

    Return Value

    true if other is lighter, otherwise false

  • Returns a Boolean value that indicates whether a given color is darker than the receiver (compering their brightness values - from HSBA color space) - parameter other: the other color to compare to - returns: true if other is darker, otherwise false - seealso: lighter(than:) - seealso: darken(_:) - seealso: lighten(_:)

    Declaration

    Swift

    public func darker(than other: UIColor) -> Bool

    Parameters

    other

    the other color to compare to

    Return Value

    true if other is darker, otherwise false