UIFont line height

Viewed 280

Is there any way to set the lineHeight of a UIFont? I know that NSAttributedString can be used to achieve this, but this doesn't suit my case, I would really like to just manipulate font of a UILabel instead. I have found that I can manipulate various properties of a font like this:

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

But I haven't found a way to set line height like this. Either line height or ascender and descender, etc

0 Answers
Related