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,26 +215,14 @@ static inline void lazyCheckIOS7()
|
||||||
|
|
||||||
static CGSize _calculateStringSize(NSString *str, id font, CGSize *constrainSize)
|
static CGSize _calculateStringSize(NSString *str, id font, CGSize *constrainSize)
|
||||||
{
|
{
|
||||||
NSArray *listItems = [str componentsSeparatedByString: @"\n"];
|
|
||||||
CGSize dim = CGSizeZero;
|
|
||||||
CGSize textRect = CGSizeZero;
|
CGSize textRect = CGSizeZero;
|
||||||
textRect.width = constrainSize->width > 0 ? constrainSize->width
|
textRect.width = constrainSize->width > 0 ? constrainSize->width
|
||||||
: 0x7fffffff;
|
: 0x7fffffff;
|
||||||
textRect.height = constrainSize->height > 0 ? constrainSize->height
|
textRect.height = constrainSize->height > 0 ? constrainSize->height
|
||||||
: 0x7fffffff;
|
: 0x7fffffff;
|
||||||
|
|
||||||
for (NSString *s in listItems)
|
CGSize dim = [s sizeWithFont:font constrainedToSize:textRect];
|
||||||
{
|
|
||||||
CGSize tmp = [s sizeWithFont:font constrainedToSize:textRect];
|
|
||||||
|
|
||||||
if (tmp.width > dim.width)
|
|
||||||
{
|
|
||||||
dim.width = tmp.width;
|
|
||||||
}
|
|
||||||
|
|
||||||
dim.height += tmp.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
dim.width = ceilf(dim.width);
|
dim.width = ceilf(dim.width);
|
||||||
dim.height = ceilf(dim.height);
|
dim.height = ceilf(dim.height);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue