Skip to content

Commit d3a6a3f

Browse files
EddyVerbruggenHristo Hristov
authored andcommitted
Line-height property breaks text alignment (iOS) (NativeScript#4909)
1 parent 1b9610b commit d3a6a3f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

tns-core-modules/ui/text-base/text-base.ios.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ export class TextBase extends TextBaseCommon {
129129
if (this.style.lineHeight) {
130130
const paragraphStyle = NSMutableParagraphStyle.alloc().init();
131131
paragraphStyle.lineSpacing = this.lineHeight;
132+
// make sure a possible previously set text alignment setting is not lost when line height is specified
133+
paragraphStyle.alignment = (<UITextField | UITextView | UILabel>this.nativeViewProtected).textAlignment;
132134
attrText.addAttributeValueRange(NSParagraphStyleAttributeName, paragraphStyle, { location: 0, length: attrText.length });
133135
}
134136

@@ -167,6 +169,8 @@ export class TextBase extends TextBaseCommon {
167169
if (style.lineHeight) {
168170
const paragraphStyle = NSMutableParagraphStyle.alloc().init();
169171
paragraphStyle.lineSpacing = style.lineHeight;
172+
// make sure a possible previously set text alignment setting is not lost when line height is specified
173+
paragraphStyle.alignment = (<UITextField | UITextView | UILabel>this.nativeViewProtected).textAlignment;
170174
dict.set(NSParagraphStyleAttributeName, paragraphStyle);
171175
}
172176

0 commit comments

Comments
 (0)