开发者

UILineBreakModeTailTruncation in sizeWithFont:constrainedToSize:lineBreakMode: is ignored

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜