From e7626375abc650c3a6c28da5c69339f5a12097f0 Mon Sep 17 00:00:00 2001 From: acton393 Date: Thu, 22 Sep 2016 16:05:28 +0800 Subject: [PATCH] * [ios] fix style line-height conflict with text-align --- ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m index 3c78f02b49..ad80586a05 100644 --- a/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m +++ b/ios/sdk/WeexSDK/Sources/Component/WXTextComponent.m @@ -261,24 +261,23 @@ - (NSAttributedString *)buildAttributeString } else if(_textDecoration == WXTextDecorationLineThrough){ [attributedString addAttribute:NSStrikethroughStyleAttributeName value:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:NSMakeRange(0, string.length)]; } + + NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new]; if (_textAlign) { - NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new]; paragraphStyle.alignment = _textAlign; - [attributedString addAttribute:NSParagraphStyleAttributeName - value:paragraphStyle - range:(NSRange){0, attributedString.length}]; } if (_lineHeight) { - NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new]; paragraphStyle.maximumLineHeight = _lineHeight; paragraphStyle.minimumLineHeight = _lineHeight; + } + + if (_lineHeight || _textAlign) { [attributedString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:(NSRange){0, attributedString.length}]; } - return attributedString; }