From 9dcc1f8193f3d9b215faca733b2238635c665cd3 Mon Sep 17 00:00:00 2001 From: Ricardo Quesada Date: Wed, 27 Jul 2016 07:44:00 -0700 Subject: [PATCH] Compile on macOS 10.10 and lower --- cocos/platform/mac/CCDevice-mac.mm | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/cocos/platform/mac/CCDevice-mac.mm b/cocos/platform/mac/CCDevice-mac.mm index 1cfc183212..13547ca7f7 100644 --- a/cocos/platform/mac/CCDevice-mac.mm +++ b/cocos/platform/mac/CCDevice-mac.mm @@ -133,10 +133,16 @@ static NSSize _calculateRealSizeForString(NSAttributedString **str, id font, NSS NSMutableAttributedString *mutableString = [[*str mutableCopy] autorelease]; *str = __attributedStringWithFontSize(mutableString, fontSize); - CGSize fitSize = [*str boundingRectWithSize:CGSizeMake( CGFLOAT_MAX, CGFLOAT_MAX) - options:NSStringDrawingUsesLineFragmentOrigin - context:nil].size; - +#ifdef __MAC_10_11 + #if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_11 + CGSize fitSize = [*str boundingRectWithSize:CGSizeMake( CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin context:nil].size; + #else + CGSize fitSize = [*str boundingRectWithSize:CGSizeMake( CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin].size; + #endif +#else + CGSize fitSize = [*str boundingRectWithSize:CGSizeMake( CGFLOAT_MAX, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin].size; +#endif + if(fitSize.width == 0 || fitSize.height == 0) continue; actualSize.size = fitSize; @@ -159,10 +165,16 @@ static NSSize _calculateRealSizeForString(NSAttributedString **str, id font, NSS NSMutableAttributedString *mutableString = [[*str mutableCopy] autorelease]; *str = __attributedStringWithFontSize(mutableString, fontSize); - - CGSize fitSize = [*str boundingRectWithSize:CGSizeMake( constrainSize.width, CGFLOAT_MAX) - options:NSStringDrawingUsesLineFragmentOrigin - context:nil].size; + +#ifdef __MAC_10_11 + #if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_11 + CGSize fitSize = [*str boundingRectWithSize:CGSizeMake( constrainSize.width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin context:nil].size; + #else + CGSize fitSize = [*str boundingRectWithSize:CGSizeMake( constrainSize.width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin].size; + #endif +#else + CGSize fitSize = [*str boundingRectWithSize:CGSizeMake( constrainSize.width, CGFLOAT_MAX) options:NSStringDrawingUsesLineFragmentOrigin].size; +#endif if(fitSize.width == 0 || fitSize.height == 0) continue; actualSize.size = fitSize;