UIColor

public extension UIColor
  • Uses a NSKeyedArchiver to encode the color into a data object.

    Declaration

    Swift

    func asData() -> Data?

    Return Value

    The encoded color as a data object.

  • A random opaque color.

    Declaration

    Swift

    static var random: UIColor { get }
  • Creates a color from a hex string. Returns nil if the hex string is invalid.

    Declaration

    Swift

    convenience init?(hex: String)

    Parameters

    hex

    The hex string value, e.g. “ffe700” or “FFE700FF”. The string must have exactly 6 or 8 characters without any leading hashmark (#). Every 2 character block represents a color value and range from 00 to FF. The first two characters describe the red part. The second two characters describe the green part. The third two characters describe the blue part. The first three color parts are mandatory. The fourth two characters describe the alpha part which is optional. When no alpha is provided it will be treated as fully opaque (FF) with an alpha value of 1.

  • Initializes a UIColor with a RGBA struct.

    Declaration

    Swift

    convenience init(rgba: RgbaColor)
  • Converts a UIColor into a SwiftUI Color view.

    Declaration

    Swift

    var colorView: Color { get }
  • Returns the rgba values of this color.

    Declaration

    Swift

    var rgbaColor: RgbaColor? { get }
  • A struct containing the RGBA values of a color.

    See more

    Declaration

    Swift

    struct RgbaColor : Codable, Equatable