From d3a6a3f7820cb9f4a944991ddad66c45b6a62dd4 Mon Sep 17 00:00:00 2001 From: Eddy Verbruggen Date: Fri, 20 Oct 2017 07:35:11 +0200 Subject: [PATCH] Line-height property breaks text alignment (iOS) (#4909) --- tns-core-modules/ui/text-base/text-base.ios.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tns-core-modules/ui/text-base/text-base.ios.ts b/tns-core-modules/ui/text-base/text-base.ios.ts index 3f4d0ba39..f711086e3 100644 --- a/tns-core-modules/ui/text-base/text-base.ios.ts +++ b/tns-core-modules/ui/text-base/text-base.ios.ts @@ -129,6 +129,8 @@ export class TextBase extends TextBaseCommon { if (this.style.lineHeight) { const paragraphStyle = NSMutableParagraphStyle.alloc().init(); paragraphStyle.lineSpacing = this.lineHeight; + // make sure a possible previously set text alignment setting is not lost when line height is specified + paragraphStyle.alignment = (this.nativeViewProtected).textAlignment; attrText.addAttributeValueRange(NSParagraphStyleAttributeName, paragraphStyle, { location: 0, length: attrText.length }); } @@ -167,6 +169,8 @@ export class TextBase extends TextBaseCommon { if (style.lineHeight) { const paragraphStyle = NSMutableParagraphStyle.alloc().init(); paragraphStyle.lineSpacing = style.lineHeight; + // make sure a possible previously set text alignment setting is not lost when line height is specified + paragraphStyle.alignment = (this.nativeViewProtected).textAlignment; dict.set(NSParagraphStyleAttributeName, paragraphStyle); }