UIColor
class UIColor : NSObject, NSSecureCoding, NSCopying
-
Function generate red, green, blue and alpha values from UIColor
Declaration
Swift
public func rgb() -> (red: CGFloat, green: CGFloat, blue: CGFloat, alpha: CGFloat)?Return Value
A tuple with (
red,green,blue,alpha) values -
Function generate hex string from UIColor
Declaration
Swift
public func toHexString() -> String -
Convenience constructor which from hex value of color generates UIColor
Declaration
Swift
public convenience init(hexString: String)Parameters
hexStringThe hex value of color
-
Generates random color
Declaration
Swift
public static func generateRandomColor(from sourceColor: UIColor?) -> UIColorParameters
fromThe optional sourceColor which is treated like a ‘mask’, e.g. if you put here white with alpha 0.8, then every generated color will be pastel
View on GitHub
UIColor Extension Reference