Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UILabel text truncatingtail dots color

I have a UILabel with textColor set to white. However, the truncation at the end of the label is still black.

I don't have reputation to post image so here is a link. Sorry in advance if the link doesn't work.

I am using UICollectionView and the text is UILabel, here is my code for the label:

    UILabel *nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(8.0f, 4.0f, 135.0f, 36.0f)];
    nameLabel.numberOfLines = 2;
    nameLabel.lineBreakMode = NSLineBreakByTruncatingTail;
    nameLabel.text = _name;
    nameLabel.font = [UIFont fontWithName:@"STHeitiSC-Medium" size:15.0f];
    [nameLabel sizeToFit];
    nameLabel.textColor = [UIColor whiteColor];
    [purpleMask addSubview:nameLabel];

Has anyone ran into this kind of issue?

like image 451
timlwting Avatar asked Oct 21 '22 11:10

timlwting


1 Answers

add something like this:

NSMutableAttributedString *string = [[NSMutableAttributedString alloc] initWithString:@"Presenting the great..."];
[string addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:20.0] range:NSMakeRange(24, 11)];

        nameLabel.attributedText =  string;
like image 116
SilentStalker Avatar answered Nov 04 '22 21:11

SilentStalker