当前位置: 首页 > 工具软件 > Font Label > 使用案例 >

html设置label的字体大小,swift - label 的font 设置 文字字体和大小

计寒
2023-12-01

设置字体和颜色

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, 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: alpha)

}

}

原文:https://www.cnblogs.com/qingzZ/p/10107569.html

 类似资料: