I'm programming on Objective C
. I have a UITableView
with UILabel
's. How to detect ellipsis in a UILabel
?
First we can get width of the text which will be rendered in label. Then we can compare that width against the width of the label. If that width exceeds then string is truncated otherwise not.
UPDATE
If label is having lines then count number of lines and check against lablewidth*numofLines
UILabel *lblAppTitle = (UILabel*)[self.view viewWithTag:777];
CGSize stringSize = [lblAppTitle.text sizeWithFont:lblAppTitle.font];
//Count Number of lines
[lblAppTitle sizeToFit];
int numLines = (int)(lblAppTitle.frame.size.height/lblAppTitle.font.leading);
if (stringSize.width > (lblAppTitle.frame.size.width)*numLines)
NSLog(@"truncated string");
else
NSLog(@"did not truncate string");
Hope this helps you.