加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 05:09:15 所属栏目:百科 来源:网络整理
导读:? 设置字体和颜色 lab.textColor = UIColor.init(hexColor: "795928") lab.font = UIFont.systemFont(ofSize: 32,weight: UIFont.Weight.black) 设置html 导图颜色 extension UIColor { /// 用十六进制颜色创建UIColor /// /// - Parameter hexColor: 十六进

?

设置字体和颜色

        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)
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读