Color
extension Color
-
从16进制创建Color
Declaration
Swift
public static func color(_ hex: Int, _ alpha: Double = 1) -> Color
Parameters
hex
十六进制值,格式0xFFFFFF
alpha
透明度可选,默认1
Return Value
Color
-
从RGB创建Color
Declaration
Swift
public static func color(_ red: Double, _ green: Double, _ blue: Double, _ alpha: Double = 1) -> Color
Parameters
red
红色值
green
绿色值
blue
蓝色值
alpha
透明度可选,默认1
Return Value
Color
-
从十六进制字符串初始化,支持RGB、RGBA|ARGB,格式:"20B2AA", “#FFFFFF",失败时返回clear
Declaration
Swift
public static func color(_ hexString: String, _ alpha: Double = 1) -> Color
Parameters
hexString
十六进制字符串
alpha
透明度可选,默认1
Return Value
Color
-
Color转换为UIColor,失败时返回clear
Declaration
Swift
public func toUIColor() -> UIColor
Return Value
UIColor