mirror of https://github.com/axmolengine/axmol.git
Cocos2d-x used a deprecated method to get the content size of a CCLabelTTF on iOS 7.
This commit is contained in:
parent
533a454914
commit
ac916c3027
|
@ -221,7 +221,14 @@ static CGSize _calculateStringSize(NSString *str, id font, CGSize *constrainSize
|
||||||
textRect.height = constrainSize->height > 0 ? constrainSize->height
|
textRect.height = constrainSize->height > 0 ? constrainSize->height
|
||||||
: 0x7fffffff;
|
: 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.width = ceilf(dim.width);
|
||||||
dim.height = ceilf(dim.height);
|
dim.height = ceilf(dim.height);
|
||||||
|
|
Loading…
Reference in New Issue