Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Old question, but you can do it now (easily).</p> <pre><code>NSMutableAttributedString *attributedString; attributedString = [[NSMutableAttributedString alloc] initWithString:@"Please get wider"]; [attributedString addAttribute:NSKernAttributeName value:@5 range:NSMakeRange(10, 5)]; [self.label setAttributedText:attributedString]; </code></pre> <p><img src="https://i.stack.imgur.com/oK6sW.png" alt="enter image description here"></p> <p>For Nov 2013, Just to expand on this great answer, here's some totally typical code. Usually you'd set the font as well. Note in the comments the old-fashioned way using ordinary old .text. Hope it helps someone</p> <pre><code>NSString *yourText = @"whatever"; UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0,0,0,0)]; // simple approach with no tracking... // label.text = yourText; // [label setFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:24]]; NSMutableAttributedString *attributedString; attributedString = [[NSMutableAttributedString alloc] initWithString:yourText]; [attributedString addAttribute:NSKernAttributeName value:[NSNumber numberWithFloat:2.0] range:NSMakeRange(0, [yourText length])]; [attributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Light" size:24] range:NSMakeRange(0, [yourText length])]; label.attributedText = attributedString; label.textColor = [UIColor blackColor]; label.backgroundColor = [UIColor clearColor]; label.textAlignment = NSTextAlignmentCenter; [label sizeToFit]; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload