I have one UITableView. Moreover, each cell contains a UILabel. But the text UILabeldoes not truncate if it exceeds the frame width UILabel.
I tried the following options but nothing works.
1> set LineBreakModehow NSLineBreakByTruncatingTailandsetNumberOfLines:1
2> set LineBreakModeas NSLineBreakByWordWrapping`setNumberOfLines: 1
The storyboard also has the same settings.
Here is the code snippet:
NSString * fullName;
UILabel *label = (UILabel *)[cell.contentView viewWithTag:100];
NSLog(@"textlabel width: %f , text size : %d ", label.bounds.size.width,fullName.length);
label.adjustsFontSizeToFitWidth = NO;
label.text = fullName;
[label setLineBreakMode:NSLineBreakByTruncatingTail];
[label setNumberOfLines:1];
[label sizeToFit];
[label setTextColor:[UIColor whiteColor]];
source
share