From 770f3d7f8e77aa62a3626f52542b1898c82acf21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=82=96=E5=B3=B0?= Date: Tue, 29 Dec 2015 18:31:20 +0800 Subject: [PATCH] Fix boundingRectWithSize compile failed with OSX 10.10 or lower version SDK --- cocos/platform/mac/CCDevice-mac.mm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cocos/platform/mac/CCDevice-mac.mm b/cocos/platform/mac/CCDevice-mac.mm index 970e16805d..af59c375fa 100644 --- a/cocos/platform/mac/CCDevice-mac.mm +++ b/cocos/platform/mac/CCDevice-mac.mm @@ -73,7 +73,15 @@ static NSSize _calculateStringSize(NSString *str, id font, CGSize *constrainSize NSSize dim; NSDictionary *attibutes = @{NSFontAttributeName:font}; +#ifdef __MAC_10_11 + #if __MAC_OS_X_VERSION_MAX_ALLOWED >= __MAC_10_11 dim = [str boundingRectWithSize:textRect options:(NSStringDrawingOptions)(NSStringDrawingUsesLineFragmentOrigin) attributes:attibutes context:nil].size; + #else + dim = [str boundingRectWithSize:textRect options:(NSStringDrawingOptions)(NSStringDrawingUsesLineFragmentOrigin) attributes:attibutes].size; + #endif +#else + dim = [str boundingRectWithSize:textRect options:(NSStringDrawingOptions)(NSStringDrawingUsesLineFragmentOrigin) attributes:attibutes].size; +#endif dim.width = ceilf(dim.width); dim.height = ceilf(dim.height);