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 (将#修改为@)