设置字体和颜色
lab.textColor = UIColor.init(hexColor: "795928") lab.font = UIFont.systemFont(ofSize: 32,weight: UIFont.Weight.black)
设置html 导图颜色
extension UIColor { /// 用十六进制颜色创建UIColor /// /// - Parameter hexColor: 十六进制颜色 (0F0F0F) convenience init(hexColor: String) { // 存储转换后的数值 var red:UInt32 = 0,green:UInt32 = 0,blue:UInt32 = 0 // 分别转换进行转换 Scanner(string: hexColor[0..<2]).scanHexInt32(&red) Scanner(string: hexColor[2..<4]).scanHexInt32(&green) Scanner(string: hexColor[4..<6]).scanHexInt32(&blue) self.init(red: CGFloat(red)/255.0,green: CGFloat(green)/255.0,blue: CGFloat(blue)/255.0,alpha: 1.0) } convenience init(hexColor: String,alpha: CGFloat) { // 存储转换后的数值 var red:UInt32 = 0,alpha: alpha) } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。