Skip to content

Commit 0416f7e

Browse files
manoldonevADjenkov
authored andcommitted
fix(ios-textview): text alignment reset to default on blur (#6903)
1 parent 57f07a3 commit 0416f7e

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ export class TextBase extends TextBaseCommon {
138138
paragraphStyle.lineBreakMode = this.nativeTextViewProtected.lineBreakMode;
139139
}
140140
attrText.addAttributeValueRange(NSParagraphStyleAttributeName, paragraphStyle, { location: 0, length: attrText.length });
141+
} else if (this.nativeTextViewProtected instanceof UITextView) {
142+
const paragraphStyle = NSMutableParagraphStyle.alloc().init();
143+
paragraphStyle.alignment = (<UITextView>this.nativeTextViewProtected).textAlignment;
144+
attrText.addAttributeValueRange(NSParagraphStyleAttributeName, paragraphStyle, { location: 0, length: attrText.length });
141145
}
142146

143147
if (this.nativeTextViewProtected instanceof UIButton) {
@@ -175,6 +179,7 @@ export class TextBase extends TextBaseCommon {
175179
dict.set(NSKernAttributeName, style.letterSpacing * this.nativeTextViewProtected.font.pointSize);
176180
}
177181

182+
const isTextView = this.nativeTextViewProtected instanceof UITextView;
178183
if (style.lineHeight) {
179184
const paragraphStyle = NSMutableParagraphStyle.alloc().init();
180185
paragraphStyle.lineSpacing = style.lineHeight;
@@ -185,9 +190,12 @@ export class TextBase extends TextBaseCommon {
185190
paragraphStyle.lineBreakMode = this.nativeTextViewProtected.lineBreakMode;
186191
}
187192
dict.set(NSParagraphStyleAttributeName, paragraphStyle);
193+
} else if (isTextView) {
194+
const paragraphStyle = NSMutableParagraphStyle.alloc().init();
195+
paragraphStyle.alignment = (<UITextView>this.nativeTextViewProtected).textAlignment;
196+
dict.set(NSParagraphStyleAttributeName, paragraphStyle);
188197
}
189198

190-
const isTextView = this.nativeTextViewProtected instanceof UITextView;
191199
if (style.color && (dict.size > 0 || isTextView)) {
192200
dict.set(NSForegroundColorAttributeName, style.color.ios);
193201
}

0 commit comments

Comments
 (0)