美文网首页
swift4.0中如何使用#号的16进制颜色 hexcolor,

swift4.0中如何使用#号的16进制颜色 hexcolor,

作者: lightandall | 来源:发表于2018-08-01 10:07 被阅读10次

    在需要放#颜色的地方把 UIColor 替换成HexColor即可
    label.color = HexColor(hex: 0xf82c88, alpha: 0.95)

    其它位置使用下面的方法即可

    func HexColor(hex:integer_t, alpha:CGFloat) -> UIColor
    {
        return UIColor(red: CGFloat((hex >> 16) & 0xff)/255.0, green: CGFloat((hex >> 8) & 0xff)/255.0, blue: CGFloat(hex & 0xff)/255.0, alpha: alpha)
    }
    

    相关文章

      网友评论

          本文标题:swift4.0中如何使用#号的16进制颜色 hexcolor,

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