UAColorUtils

Objective-C

@interface UAColorUtils : NSObject

Swift

class UAColorUtils : NSObject

A collection of utilities for converting UIColors to and from various string representations.

Color Utils Internal Methods

  • Converts a hex color string of type #aarrggbb or #rrggbb into a UIColor.

    Declaration

    Objective-C

    + (nullable UIColor *)colorWithHexString:(nonnull NSString *)hexString;

    Swift

    class func color(withHexString hexString: String) -> UIColor?

    Parameters

    hexString

    A hex color string of type #aarrggbb or #rrggbb.

    Return Value

    An instance of UIColor, or nil if the color could not be correctly parsed.

  • Converts a UIColor into a hex color string of type #aarrggbb.

    Declaration

    Objective-C

    + (nullable NSString *)hexStringWithColor:(nonnull UIColor *)color;

    Swift

    class func hexString(with color: UIColor) -> String?

    Parameters

    color

    An instance of UIColor.

    Return Value

    An NSString of type #aarrggbb representing the passed color, or nil if the UIColor cannot be converted to the RGBA colorspace.