Creating a string with custom kerning (letter spacing)

suggest change

NSAttributedString (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];

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents