Why does multiline UILabel with line alignment remove 3 dots at the end?

I have a problem adding lines to my UILabel. If I don't use a line, I get 3 dots at the end of line 3 if the text overflows.

    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 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 disappear. How can I prevent three dots from being removed when adding the Text attribute?

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 points

+3


source to share


1 answer


Perhaps this helps to set the lineBreakMode

object paragraphStyle

in:NSLineBreakByTruncatingTail



+8


source







All Articles