联系人:石虎 QQ:1224614774  昵称: 嗡嘛呢叭咪哄

                      QQ群:807236138  群称: iOS 技术交流学习群

                     QQ群:713799633   群称:iOS技术交流学习群-2

 

一、例子:字体默认是 13

   参考:https://www.jianshu.com/p/cffea49a6b3f

    private lazy var titleLabel: UILabel = {
        let label = UILabel()
        label.font = UIFont.systemFont(ofSize: 13, weight: .regular)
        label.textColor = UIColor.colorWithHex("222222")
        return label
    }()

     print("font pointSize=\( titleLabel.font.pointSize) \n ascender=\( titleLabel.font.ascender)  \n descender= \( titleLabel.font.descender)  \n capHeight= \( titleLabel.font.capHeight)  \n xHeight= \( titleLabel.font.xHeight)  \n leading= \( titleLabel.font.leading)   \n lineHeight= \( titleLabel.font.lineHeight) ")

二、打印结果:

原字体大小是 13,打印结果如下

font pointSize=13.0

ascender=12.3779296875

descender= -3.1357421875

capHeight= 9.15966796875

xHeight= 6.8427734375

leading= 0.0   

lineHeight= 15.513671875

 

三、属性场景:

//            titleLabel.font.pointSize, // 返回字体大小

//            titleLabel.font.ascender,  // 基准线以上的最高y坐标

//            titleLabel.font.descender, // 基准线以下的最低y坐标

//            titleLabel.font.capHeight, // 返回大写字母的高度

//            titleLabel.font.xHeight,   // 返回小写x的高度

//            titleLabel.font.leading,   // 返回文本行的高度

//            titleLabel.font.lineHeight // 返回文本行的高度

谢谢!!!

Logo

昇腾计算产业是基于昇腾系列(HUAWEI Ascend)处理器和基础软件构建的全栈 AI计算基础设施、行业应用及服务,https://devpress.csdn.net/organization/setting/general/146749包括昇腾系列处理器、系列硬件、CANN、AI计算框架、应用使能、开发工具链、管理运维工具、行业应用及服务等全产业链

更多推荐