I have a problem with adding linespacing to my UILabel. If I don't use linespacing, I get 3 dots at the end of line 3 if the text is overflowing.
UILabel *labelBlurb = [[UILabel alloc] initWithFrame:CGRectMake(marginLeft, 15+20, 295, 60)];
[labelBlurb setNumberOfLines:3];
[labelBlurb setText:blurb];
[labelBlurb setLineBreakMode:NSLineBreakByTruncatingTail];
[labelBlurb setAdjustsFontSizeToFitWidth:NO];
[labelBlurb setTextColor:[UIColor colorWithRed:38.0/255.0 green:38.0/255.0 blue:38.0/255.0 alpha:1.0]];
[labelBlurb setBackgroundColor:[UIColor clearColor]];
[labelBlurb setFont:[UIFont fontWithName:@"HelveticaNeue" size:12]];
But when I add the attributed text like this:
attributedString = [[NSMutableAttributedString alloc] initWithString:blurb];
paragraphStyle = [[NSMutableParagraphStyle alloc] init];
[paragraphStyle setLineSpacing:3.5];
[attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, [blurb length])];
labelBlurb.attributedText = attributedString;
[view addSubview:labelBlurb];
The 3 dots at the end disappears. How do I prevent the 3 dots from being removed when adding attributedText?
This is what I want WITH 3.5 linespacing:
Bacon ipsum dolor sit amet doner pork belly leberkas pastrami.
Short loin pastrami ribeye boudin tenderloin. Shoulder short ribs beef
pancetta. Salami biltong tongue ham hock beef ribs meatball.. <-- 3 dots
Maybe it helps to set the lineBreakMode
of the paragraphStyle
-object to :NSLineBreakByTruncatingTail
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With