Cocos2d-x used a deprecated method to get the content size of a CCLabelTTF on iOS 7.

This commit is contained in:
Dhilan007 2014-09-22 18:01:13 +08:00
parent 533a454914
commit ac916c3027
1 changed files with 8 additions and 1 deletions

View File

@ -221,7 +221,14 @@ static CGSize _calculateStringSize(NSString *str, id font, CGSize *constrainSize
textRect.height = constrainSize->height > 0 ? constrainSize->height
: 0x7fffffff;
CGSize dim = [str sizeWithFont:font constrainedToSize:textRect];
CGSize dim;
if(s_isIOS7OrHigher){
NSDictionary *attibutes = @{NSFontAttributeName:font};
dim = [str boundingRectWithSize:textRect options:(NSStringDrawingOptions)(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading) attributes:attibutes context:nil].size;
}
else {
dim = [str sizeWithFont:font constrainedToSize:textRect];
}
dim.width = ceilf(dim.width);
dim.height = ceilf(dim.height);