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; }