If I have a UIFont
object, is it possible to convert it to bold? I don\'t know the font name, I just have a UIFont object. What I want is a function like
This is a very old thread but someone may be interested in how to do this in Swift 5 nowadays.
Easy like this:
var font: UIFont = UIFont.systemFont(ofSize: 18)
if let newDescriptor = font.fontDescriptor.withSymbolicTraits(.traitBold) {
font = UIFont(descriptor: newDescriptor, size: font.pointSize)
}