想找个swift版的中国风颜色大全,百度了半天也没找到。😤。于是自己动手撸了一个。感觉有些颜色和名字不太搭配,网上的素材看来也不是太准确啊,将就用吧……
用法:直接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")
}
}