Creating a string with custom kerning (letter spacing)
suggest changeNSAttributedString (and its mutable subclass NSMutableAttributedString) can represent strings whose appearance varies by range.
A common use is custom kerning (letter spacing).
The following example, where label is a UILabel, increases kerning for the word “kerning”:
NSMutableAttributedString *attributedString;
attributedString = [[NSMutableAttributedString alloc] initWithString:@"Apply kerning"];
[attributedString addAttribute:NSKernAttributeName value:@5 range:NSMakeRange(6, 7)];
[label setAttributedText:attributedString];
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents