From 63a68632a5b97a2d2292cff7a70a809564d3d7c0 Mon Sep 17 00:00:00 2001 From: Dhilan007 Date: Wed, 11 Jun 2014 21:49:08 +0800 Subject: [PATCH] fixed calculating height of multi-line string was incorrect on IOS. --- cocos/platform/ios/CCDevice.mm | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/cocos/platform/ios/CCDevice.mm b/cocos/platform/ios/CCDevice.mm index 5eeaf7ccaa..9246327882 100644 --- a/cocos/platform/ios/CCDevice.mm +++ b/cocos/platform/ios/CCDevice.mm @@ -215,26 +215,14 @@ 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);