Fattie needs to reward an present reply.
I’m attempting so as to add a system font of weight “Heavy” (not daring) and likewise attempt to make it italic. I noticed different stackoverflow options nevertheless it doesn’t appear to work. Here’s what I’ve finished:
let percentageLabel: UILabel = {
let label = UILabel()
label.textual content = “0”
label.textAlignment = .middle
label.textColor = .white
label.font = UIFont.systemFont(ofSize: 32, weight: .heavy, traits: .traitItalic)
return label
}()
Extension as urged in a stack overflow publish
extension UIFont {
static func systemFont(ofSize: CGFloat, weight: UIFont.Weight, traits: UIFontDescriptor.SymbolicTraits) -> UIFont? {
let font = UIFont.systemFont(ofSize: ofSize, weight: weight)
if let descriptor = font.fontDescriptor.withSymbolicTraits(traits) {
return UIFont(descriptor: descriptor, measurement: ofSize)
}
return nil
}
}
Factor is after I tried all urged options, daring and italic appears to work BUT black and italic would not work. It’s nonetheless rendered as common italic.