mirror of https://github.com/axmolengine/axmol.git
fixed calculating height of multi-line string was incorrect on IOS.
This commit is contained in:
parent
0ad57bdde7
commit
63a68632a5
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue