微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

UIFont 行高

如何解决UIFont 行高

有没有办法设置 lineHeightUIFont?我知道 NSAttributedString 可以用来实现这一点,但这不适合我的情况,我真的很想只操纵 fontUILabel 代替。 我发现我可以像这样操作字体的各种属性

extension UIFont {
    func withAttributes(_ attributes: [UIFontDescriptor.AttributeName : Any]) -> UIFont {
        let newDescriptor = fontDescriptor.addingAttributes(attributes)
        return UIFont(descriptor: newDescriptor,size: pointSize)
    }
}
let newFont = font.withAttributes([.traits: [UIFontDescriptor.TraitKey.weight : UIFont.Weight.bold]])

但是我还没有找到像这样设置行高的方法。 行高或上升和下降等

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。