diff --git a/cocos2dx/platform/ios/FontLabel/FontLabel.m b/cocos2dx/platform/ios/FontLabel/FontLabel.m index 3e7ac0e323..1e97d650d9 100644 --- a/cocos2dx/platform/ios/FontLabel/FontLabel.m +++ b/cocos2dx/platform/ios/FontLabel/FontLabel.m @@ -118,15 +118,18 @@ } size.width = MIN(size.width, origSize.width); // adjust the point for alignment - switch (self.textAlignment) { - case UITextAlignmentLeft: + switch ((NSTextAlignment)self.textAlignment) { + case NSTextAlignmentLeft: break; - case UITextAlignmentCenter: + case NSTextAlignmentCenter: point.x += (origSize.width - size.width) / 2.0f; break; - case UITextAlignmentRight: + case NSTextAlignmentRight: point.x += origSize.width - size.width; break; + case NSTextAlignmentJustified: + case NSTextAlignmentNatural: + default: break; } [self.text drawAtPoint:point forWidth:size.width withZFont:actualFont lineBreakMode:self.lineBreakMode]; } else { diff --git a/cocos2dx/platform/ios/FontLabel/FontLabelStringDrawing.m b/cocos2dx/platform/ios/FontLabel/FontLabelStringDrawing.m index 8884fa468d..bad5abd028 100644 --- a/cocos2dx/platform/ios/FontLabel/FontLabelStringDrawing.m +++ b/cocos2dx/platform/ios/FontLabel/FontLabelStringDrawing.m @@ -637,16 +637,19 @@ static CGSize drawOrSizeTextConstrainedToSize(BOOL performDraw, NSString *string // draw if (performDraw) { - switch (alignment) { - case UITextAlignmentLeft: + switch ((NSTextAlignment)alignment) { + case NSTextAlignmentLeft: drawPoint.x = 0; break; - case UITextAlignmentCenter: + case NSTextAlignmentCenter: drawPoint.x = (constrainedSize.width - lineSize.width) / 2.0f; break; - case UITextAlignmentRight: + case NSTextAlignmentRight: drawPoint.x = constrainedSize.width - lineSize.width; break; + case NSTextAlignmentJustified: + case NSTextAlignmentNatural: + default: break; } NSUInteger stopGlyphIdx = glyphIdx; NSUInteger lastRunIdx = currentRunIdx;