Reputation: 3668
I'm not sure if I'm missing something obvious but I've looked around on SO and couldn't find an answer.
Basically, despite what this question says, UILabel plain text and attributed text looks different. For example, both labels below are system font 15pt, with the black one using attributed text and the gray one using plain text. Apparently the black one is wider than the gray one.
I understand I can set kerning on attributed text to adjust its appearance. My question is though what's the value I should set to make it look the same as Apple's default? Is there a way for me to "leave the kerning value at the default"?
Thank you!
Upvotes: 1
Views: 679
Reputation: 578
According to the documentation for the UILabel attributed text property
To turn on auto-kerning on the label, set kern of the string to null.
Looks like auto-kerning for plain text is on by default, for attributed text is off by default. Here's how to turn auto-kerning back on for the attributed text property:
let label = UILabel()
let attributes = [NSAttributedString.Key.kern: kCFNull!]
label.attributedText = NSMutableAttributedString(string: "Text", attributes: attributes)
Upvotes: 2