I'm using sizeWithFont:constrainedToSize:lineBreakMode:
to calculate the actual height of a UILabel
.
However, the height I get is always based on the complete NSString
(before it gets truncated).
In fact, both sizeWithFont:constrainedToSize:lineBreakMode:
and sizeWithFont:constrainedToSize:
produce identical results as if the UILineBreakModeTailTruncation
gets ignored !
This code produces 60.000000
no matter what I try, but the first result should be less than 60. Any idea why ?
CGSize aSize;
aSize=[@"One two three four five six seven eight nine ten" sizeWithFont:[UIFont boldSystemFontOfSize:12] constrainedToSize:CGSizeMake(100, 100)];
NSLog(@"aSize.height: %f",aSize.height); //returns 60.000000
aSize=[@"One two three four five six seven eight nine ten" sizeWithFont:[UIFont boldSystemFontOfSize:12] constrainedToSize:CGSizeMake(100, 100) lineBreakMode:UILineBreakModeTailTruncation];
NSLog(@"aSize.height: %f开发者_如何学C",aSize.height); //returns 60.000000
Thank you.
Sorry, I found out that the string did not get truncated because the frame can contain the entire string.
精彩评论