I thought this was an interesting question, so built and barely tested this...
- (void)setText:(UILabel *)label withText:(NSString *)text andTruncationSuffix:(NSString *)truncationSuffix {
// just set the text if it fits using the minimum font
//
CGSize size = [text sizeWithFont:[UIFont systemFontOfSize:label.minimumFontSize]];
if (size.width <= label.bounds.size.width) {
label.text = text;
return;
}
// build a truncated version of the text (using the custom truncation text)
// and shrink the truncated text until it fits
NSInteger lastIndex = text.length;
CGFloat width = MAXFLOAT;
NSString *subtext, *ellipticalText;
while (lastIndex > 0 && width > label.bounds.size.width) {
subtext = [text substringToIndex:lastIndex];
ellipticalText = [subtext stringByAppendingString:truncationSuffix];
width = [ellipticalText sizeWithFont:[UIFont systemFontOfSize:label.minimumFontSize]].width;
lastIndex--;
}
label.text = ellipticalText;
}
Call it like this:
[self setText:self.label withText:@"Now is the time for all good men to come to the aid of their country" andTruncationSuffix:@" more"];
If this works for you, you could consider adding a subclass of UILabel, using this to override the setText: method, and adding a property called truncatedSuffix.