fixed calculating height of multi-line string was incorrect on IOS.

This commit is contained in:
Dhilan007 2014-06-11 21:49:08 +08:00
parent 0ad57bdde7
commit 63a68632a5
1 changed files with 2 additions and 14 deletions

View File

@ -215,25 +215,13 @@ static inline void lazyCheckIOS7()
static CGSize _calculateStringSize(NSString *str, id font, CGSize *constrainSize)
{
NSArray *listItems = [str componentsSeparatedByString: @"\n"];
CGSize dim = CGSizeZero;
CGSize textRect = CGSizeZero;
textRect.width = constrainSize->width > 0 ? constrainSize->width
: 0x7fffffff;
textRect.height = constrainSize->height > 0 ? constrainSize->height
: 0x7fffffff;
for (NSString *s in listItems)
{
CGSize tmp = [s sizeWithFont:font constrainedToSize:textRect];
if (tmp.width > dim.width)
{
dim.width = tmp.width;
}
dim.height += tmp.height;
}
CGSize dim = [s sizeWithFont:font constrainedToSize:textRect];
dim.width = ceilf(dim.width);
dim.height = ceilf(dim.height);