美文网首页
颜色工具类UIColorExtension-swift

颜色工具类UIColorExtension-swift

作者: HAKA | 来源:发表于2017-03-01 11:10 被阅读96次
    import UIKit
    extension UIColor {
    static func rgb(_ red: CGFloat, green: CGFloat, blue: CGFloat) -> UIColor {
        return UIColor.init(red: red/255, green: green/255, blue: blue/255, alpha: 1)
    }
    
    static func colorWithHex(_ hex: UInt) -> UIColor {
        let r: CGFloat = CGFloat((hex & 0xff0000) >> 16)
        let g: CGFloat = CGFloat((hex & 0x00ff00) >> 8)
        let b: CGFloat = CGFloat(hex & 0x0000ff)
        
        return rgb(r, green: g, blue: b)
    }
    }

    相关文章

      网友评论

          本文标题:颜色工具类UIColorExtension-swift

          本文链接:https://www.haomeiwen.com/subject/ngdqgttx.html