2018-05-11

想找個swift版的中國風顏色大全,百度了半天也沒找到。??。于是自己動手擼了一個。感覺有些顏色和名字不太搭配,網(wǎng)上的素材看來也不是太準確啊,將就用吧……

用法:直接UIColor.顏色名稱就OK??

    import UIKit


extension UIColor {
func HRRGBColorFromHex(rgbValue: Int) -> UIColor {
    return UIColor(red: ((CGFloat)((rgbValue & 0xFF0000) >> 16)) / 255.0,                  green: ((CGFloat)((rgbValue & 0xFF00) >> 8)) / 255.0,
        blue: ((CGFloat)(rgbValue & 0xFF)) / 255.0,
        alpha: 1.0)
}

class func hexadecimalColor(hexadecimal:String)->UIColor{
    var cstr = hexadecimal.trimmingCharacters(in:  CharacterSet.whitespacesAndNewlines).uppercased() as NSString;
    if(cstr.length < 6){
        return UIColor.clear;
    }
    if(cstr.hasPrefix("0X")){
        cstr = cstr.substring(from: 2) as NSString
    }
    if(cstr.hasPrefix("#")){
        cstr = cstr.substring(from: 1) as NSString
    }
    if(cstr.length != 6){
        return UIColor.clear;
    }
    var range = NSRange.init()
    range.location = 0
    range.length = 2
    //r
    let rStr = cstr.substring(with: range);
    //g
    range.location = 2;
    let gStr = cstr.substring(with: range)
    //b
    range.location = 4;
    let bStr = cstr.substring(with: range)
    var r :UInt32 = 0x0;
    var g :UInt32 = 0x0;
    var b :UInt32 = 0x0;
    Scanner.init(string: rStr).scanHexInt32(&r);
    Scanner.init(string: gStr).scanHexInt32(&g);
    Scanner.init(string: bStr).scanHexInt32(&b);
    return UIColor(red: CGFloat(r)/255.0, green: CGFloat(g)/255.0, blue: CGFloat(b)/255.0, alpha: 1.0)
}

}
extension UIColor {

static var 蔚藍:UIColor {
    return hexadecimalColor(hexadecimal: "#70f3ff")
}

static var 藍: UIColor {
    return hexadecimalColor(hexadecimal: "#44cef6")
}

static var 碧藍: UIColor {
    return hexadecimalColor(hexadecimal: "#3eede7")
}

static var 石青: UIColor {
    return hexadecimalColor(hexadecimal: "#1685a9")
}

static var 靛青: UIColor {
    return hexadecimalColor(hexadecimal: "#177cb0")
}

static var 靛藍: UIColor {
    return hexadecimalColor(hexadecimal: "#065279")
}

static var 花青: UIColor {
    return hexadecimalColor(hexadecimal: "#003472")
}

static var 寶藍: UIColor {
    return hexadecimalColor(hexadecimal: "#4b5cc4")
}

static var 藍灰色: UIColor {
    return hexadecimalColor(hexadecimal: "#a1afc9")
}

static var 藏青: UIColor {
    return hexadecimalColor(hexadecimal: "#2e4e7e")
}

static var 藏藍: UIColor {
    return hexadecimalColor(hexadecimal: "#3b2e7e")
}

static var 黛: UIColor {
    return hexadecimalColor(hexadecimal: "#4a4266")
}

static var 黛綠: UIColor {
    return hexadecimalColor(hexadecimal: "#426666")
}

static var 黛藍: UIColor {
    return hexadecimalColor(hexadecimal: "#425066")
}

static var 黛紫: UIColor {
    return hexadecimalColor(hexadecimal: "#574266")
}

static var 紫色: UIColor {
    return hexadecimalColor(hexadecimal: "#8d4bb")
}

static var 紫醬: UIColor {
    return hexadecimalColor(hexadecimal: "#815463")
}

static var 醬紫: UIColor {
    return hexadecimalColor(hexadecimal: "#815467")
}

static var 紫檀: UIColor {
    return hexadecimalColor(hexadecimal: "#4c221b")
}

static var 紺青: UIColor {
    return hexadecimalColor(hexadecimal: "#003371")
}

static var 紫棠: UIColor {
    return hexadecimalColor(hexadecimal: "#56004f")
}

static var 青蓮: UIColor{
    return hexadecimalColor(hexadecimal: "#801dae")
}

static var 群青: UIColor {
    return hexadecimalColor(hexadecimal: "#4c8dae")
}

static var 雪青: UIColor {
    return hexadecimalColor(hexadecimal: "#b0a4e3")
}

static var 丁香色: UIColor {
    return hexadecimalColor(hexadecimal: "#cca4e3")
}

static var 藕色: UIColor {
    return hexadecimalColor(hexadecimal: "#edd1d8")
}

static var 藕荷色: UIColor {
    return hexadecimalColor(hexadecimal: "#e4c6d0")
}

static var 朱砂: UIColor {
    return hexadecimalColor(hexadecimal: "#ff461f")
}

static var 火紅: UIColor {
    return hexadecimalColor(hexadecimal: "#ff2d51")
}

static var 朱膘: UIColor {
    return hexadecimalColor(hexadecimal: "#f36838")
}

static var 妃色: UIColor {
    return hexadecimalColor(hexadecimal: "#ed5736")
}

static var 洋紅: UIColor {
    return hexadecimalColor(hexadecimal: "#ff4777")
}

static var 品紅: UIColor {
    return hexadecimalColor(hexadecimal: "#f00056")
}

static var 粉紅: UIColor {
    return hexadecimalColor(hexadecimal: "#ffb3a7")
}

static var 桃紅: UIColor {
    return hexadecimalColor(hexadecimal: "#f47983")
}

static var 海棠紅: UIColor {
    return hexadecimalColor(hexadecimal: "#db5a6b")
}

static var 櫻桃色: UIColor {
    return hexadecimalColor(hexadecimal: "#c93756")
}

static var 酡顏: UIColor {
    return hexadecimalColor(hexadecimal: "#f9906f")
}
static var 銀紅: UIColor {
    return hexadecimalColor(hexadecimal: "#f05654")
}

static var 大紅: UIColor {
    return hexadecimalColor(hexadecimal: "#ff2121")
}

static var 石榴紅: UIColor {
    return hexadecimalColor(hexadecimal: "#f20c00")
}

static var 絳紫: UIColor {
    return hexadecimalColor(hexadecimal: "8c4356")
}

static var 緋紅: UIColor {
    return hexadecimalColor(hexadecimal: "#c83c23")
}

static var 胭脂: UIColor {
    return hexadecimalColor(hexadecimal: "#9d2933")
}

static var 朱紅: UIColor {
    return hexadecimalColor(hexadecimal: "#ff4c00")
}

static var 丹: UIColor {
    return hexadecimalColor(hexadecimal: "#ff4e20")
}

static var 彤: UIColor {
    return hexadecimalColor(hexadecimal: "#f35336")
}

static var 酡紅: UIColor {
    return hexadecimalColor(hexadecimal: "#dc3023")
}

static var 炎: UIColor {
    return hexadecimalColor(hexadecimal: "#ff3300")
}

static var 茜色: UIColor {
    return hexadecimalColor(hexadecimal: "#cb3a56")
}

static var 綰: UIColor {
    return hexadecimalColor(hexadecimal: "#a98175")
}

static var 檀: UIColor {
    return hexadecimalColor(hexadecimal: "#b36d61")
}

static var 嫣紅: UIColor {
    return hexadecimalColor(hexadecimal: "#ef7a82")
}

static var 棗紅: UIColor {
    return hexadecimalColor(hexadecimal: "#c32136")
}

static var 殷紅: UIColor {
    return hexadecimalColor(hexadecimal: "#be002f")
}

static var 赫赤: UIColor {
   return hexadecimalColor(hexadecimal: "#c91f37")
}

static var 銀朱: UIColor {
    return hexadecimalColor(hexadecimal: "#bf242a")
}

static var 赤: UIColor {
    return hexadecimalColor(hexadecimal: "#c3272b")
}

static var 栗色: UIColor {
    return hexadecimalColor(hexadecimal: "#60281e")
}

static var 玄色: UIColor {
    return hexadecimalColor(hexadecimal: "#622a1d")
}

static var 松花色: UIColor {
    return hexadecimalColor(hexadecimal: "#bce672")
}

static var 柳黃: UIColor {
    return hexadecimalColor(hexadecimal:"#c9dd22")
}

static var 嫩綠: UIColor {
    return hexadecimalColor(hexadecimal: "#bddd2")
}

static var 柳綠: UIColor {
    return hexadecimalColor(hexadecimal: "#afdd22")
}

static var 蔥黃: UIColor {
    return hexadecimalColor(hexadecimal: "#a3d900")
}

static var 蔥綠: UIColor {
    return hexadecimalColor(hexadecimal: "#9ed900")
}

static var 豆綠: UIColor {
    return hexadecimalColor(hexadecimal: "#9ed048")
}

static var 豆青: UIColor {
    return hexadecimalColor(hexadecimal: "#96ce54")
}

static var 油綠: UIColor {
    return hexadecimalColor(hexadecimal: "#00bc12")
}

static var 蔥青: UIColor {
    return hexadecimalColor(hexadecimal: "#0eb83a")
}

static var 青蔥: UIColor {
    return hexadecimalColor(hexadecimal: "#0aa344")
}

static var 石綠: UIColor {
    return hexadecimalColor(hexadecimal: "#16a951")
}

static var 松柏綠: UIColor {
    return hexadecimalColor(hexadecimal: "#21a675")
}

static var 松花綠: UIColor {
    return hexadecimalColor(hexadecimal: "#057784")
}

static var 綠沈: UIColor {
    return hexadecimalColor(hexadecimal: "#0c8918")
}

static var 綠色: UIColor {
    return hexadecimalColor(hexadecimal: "#00e500")
}

static var 草綠: UIColor {
    return hexadecimalColor(hexadecimal: "#40de5a")
}

static var 青翠: UIColor {
    return hexadecimalColor(hexadecimal: "#00e079")
}

static var 青色: UIColor {
    return hexadecimalColor(hexadecimal: "#00e09a")
}

static var 翡翠色: UIColor {
    return hexadecimalColor(hexadecimal: "#3de1ad")
}

static var 碧綠: UIColor {
    return hexadecimalColor(hexadecimal: "#2add9c")
}

static var 玉色: UIColor {
    return hexadecimalColor(hexadecimal: "#2edfa3")
}

static var 縹: UIColor {
    return hexadecimalColor(hexadecimal: "#7fecad")
}

static var 艾綠: UIColor {
    return hexadecimalColor(hexadecimal: "#a4e2c6")
}


static var 碧色: UIColor {
    return hexadecimalColor(hexadecimal: "#1bd1a5")
}

static var 青碧: UIColor {
    return hexadecimalColor(hexadecimal: "#48c0a3")
}

static var 銅綠: UIColor {
    return hexadecimalColor(hexadecimal: "#549688")
}

static var 竹青: UIColor {
    return hexadecimalColor(hexadecimal: "#789262")
}

static var 墨灰: UIColor {
    return hexadecimalColor(hexadecimal: "#758a99")
}

static var 墨色: UIColor {
    return hexadecimalColor(hexadecimal: "#50616b")
}

static var 鴉青: UIColor {
    return hexadecimalColor(hexadecimal: "#424c50")
}

static var 黯: UIColor {
    return hexadecimalColor(hexadecimal: "#41555d")
}

static var 櫻草色: UIColor {
    return hexadecimalColor(hexadecimal: "#eaff56")
}

static var 鵝黃: UIColor {
    return hexadecimalColor(hexadecimal: "#fff143")
}

static var 鴨黃: UIColor {
    return hexadecimalColor(hexadecimal: "#faff72")
}

static var 杏黃: UIColor {
    return hexadecimalColor(hexadecimal: "#ffa631")
}

static var 橙黃: UIColor {
    return hexadecimalColor(hexadecimal: "#ffa400")
}

static var 橙色: UIColor {
    return hexadecimalColor(hexadecimal: "#fa8c35")
}

static var 杏紅: UIColor {
    return hexadecimalColor(hexadecimal: "#ff8c31")
}

static var 橘黃: UIColor {
    return hexadecimalColor(hexadecimal: "#ff8936")
}

static var 橘紅: UIColor {
    return hexadecimalColor(hexadecimal: "#ff7500")
}

static var 藤黃: UIColor {
    return hexadecimalColor(hexadecimal: "#ffb61e")
}

static var 姜黃: UIColor {
    return hexadecimalColor(hexadecimal: "#ffc773")
}

static var 雌黃: UIColor {
    return hexadecimalColor(hexadecimal: "#ffc64b")
}

static var 赤金: UIColor {
    return hexadecimalColor(hexadecimal: "#f2be45")
}

static var 緗色: UIColor {
    return hexadecimalColor(hexadecimal: "#f0c239")
}

static var 雄黃: UIColor {
    return hexadecimalColor(hexadecimal: "#e9bb1d")
}

static var 秋香色: UIColor {
    return hexadecimalColor(hexadecimal: "#d9b611")
}

static var 金色: UIColor {
    return hexadecimalColor(hexadecimal: "#eacd76")
}

static var 牙色: UIColor {
    return hexadecimalColor(hexadecimal: "#eedeb0")
}

static var 枯黃: UIColor {
    return hexadecimalColor(hexadecimal: "#d3b17d")
}

static var 黃櫨: UIColor {
    return hexadecimalColor(hexadecimal: "#e29c45")
}

static var 烏金: UIColor {
    return hexadecimalColor(hexadecimal: "#a78e44")
}

static var 昏黃: UIColor {
    return hexadecimalColor(hexadecimal: "#c89b40")
}

static var 棕黃: UIColor {
    return hexadecimalColor(hexadecimal: "#ae7000")
}

static var 琥珀: UIColor {
    return hexadecimalColor(hexadecimal: "#ca6924")
}

static var 棕色: UIColor {
    return hexadecimalColor(hexadecimal: "#b25d25")
}

static var 茶色: UIColor {
    return hexadecimalColor(hexadecimal: "#b35c44")
}

static var 棕紅: UIColor {
    return hexadecimalColor(hexadecimal: "#9b4400")
}

static var 赭: UIColor {
    return hexadecimalColor(hexadecimal: "#9c5333")
}

static var 駝色: UIColor {
    return hexadecimalColor(hexadecimal: "#a88462")
}

static var 秋色: UIColor {
    return hexadecimalColor(hexadecimal: "#896c39")
}

static var 棕綠: UIColor {
    return hexadecimalColor(hexadecimal: "#827100")
}

static var 褐色: UIColor {
    return hexadecimalColor(hexadecimal: "#6e511e")
}

static var 棕黑: UIColor {
    return hexadecimalColor(hexadecimal: "#7c4b00")
}

static var 赭色: UIColor {
    return hexadecimalColor(hexadecimal: "#955539")
}

static var 赭石: UIColor {
    return hexadecimalColor(hexadecimal: "#845a33")
}

static var 精白: UIColor {
    return hexadecimalColor(hexadecimal: "#ffffff")
}

static var 銀白: UIColor {
    return hexadecimalColor(hexadecimal: "#e9e7ef")
}

static var 鉛白: UIColor {
    return hexadecimalColor(hexadecimal: "#f0f0f4")
}

static var 霜色: UIColor {
    return hexadecimalColor(hexadecimal: "#e9f1f6")
}

static var 雪白: UIColor {
    return hexadecimalColor(hexadecimal: "#f0fcff")
}

static var 瑩白: UIColor {
    return hexadecimalColor(hexadecimal: "#e3f9fd")
}

static var 月白: UIColor {
    return hexadecimalColor(hexadecimal: "#d6ecf0")
}

static var 象牙白: UIColor {
    return hexadecimalColor(hexadecimal: "#fffbf0")
}

static var 縞: UIColor {
    return hexadecimalColor(hexadecimal: "#f2ecde")
}

static var 魚肚白: UIColor {
    return hexadecimalColor(hexadecimal: "#fcefe8")
}

static var 白粉: UIColor {
    return hexadecimalColor(hexadecimal: "#fff2df")
}

static var 茶白: UIColor {
    return hexadecimalColor(hexadecimal: "#f3f9f1")
}

static var 鴨卵青: UIColor {
    return hexadecimalColor(hexadecimal: "#e0eee8")
}

static var 素: UIColor {
    return hexadecimalColor(hexadecimal: "#e0f0e9")
}

static var 青白: UIColor {
    return hexadecimalColor(hexadecimal: "#c0ebd7")
}

static var 蟹殼青: UIColor {
    return hexadecimalColor(hexadecimal: "#bbcdc5")
}

static var 花白: UIColor {
    return hexadecimalColor(hexadecimal: "#c2ccd0")
}

static var 老銀: UIColor {
    return hexadecimalColor(hexadecimal: "#bacac6")
}

static var 灰色: UIColor {
    return hexadecimalColor(hexadecimal: "#75878a")
}

static var 蒼色: UIColor {
    return hexadecimalColor(hexadecimal: "#75878a")
}

static var 水色: UIColor {
    return hexadecimalColor(hexadecimal: "#88ada6")
}

static var 黝: UIColor {
    return hexadecimalColor(hexadecimal: "#6b6882")
}

static var 烏色: UIColor {
    return hexadecimalColor(hexadecimal: "#725e82")
}

static var 玄青: UIColor {
    return hexadecimalColor(hexadecimal: "#3d3b4f")
}

static var 烏黑: UIColor {
    return hexadecimalColor(hexadecimal: "#392f41")
}

static var 黎: UIColor {
    return hexadecimalColor(hexadecimal: "#75664b")
}

static var 黧: UIColor {
    return hexadecimalColor(hexadecimal: "#5d513c")
}

static var 黝黑: UIColor {
    return hexadecimalColor(hexadecimal: "#665757")
}

static var 緇色: UIColor {
    return hexadecimalColor(hexadecimal: "#493131")
}

static var 煤黑: UIColor {
    return hexadecimalColor(hexadecimal: "#312520")
}

static var 漆黑: UIColor {
    return hexadecimalColor(hexadecimal: "#161823")
}

static var 黑色: UIColor {
    return hexadecimalColor(hexadecimal: "#000000")
}

}

?著作權歸作者所有,轉載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務。

相關閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容