diff --git a/nativescript-core/ui/text-base/text-base.ios.ts b/nativescript-core/ui/text-base/text-base.ios.ts index e47cf139b..568f2ef03 100644 --- a/nativescript-core/ui/text-base/text-base.ios.ts +++ b/nativescript-core/ui/text-base/text-base.ios.ts @@ -139,7 +139,12 @@ export class TextBase extends TextBaseCommon { 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.nativeTextViewProtected).textAlignment; + if (this.nativeTextViewProtected instanceof UIButton) { + paragraphStyle.alignment = (this.nativeTextViewProtected).titleLabel.textAlignment; + } else { + paragraphStyle.alignment = (this.nativeTextViewProtected).textAlignment; + } + if (this.nativeTextViewProtected instanceof UILabel) { // make sure a possible previously set line break mode is not lost when line height is specified paragraphStyle.lineBreakMode = this.nativeTextViewProtected.lineBreakMode; @@ -192,7 +197,12 @@ export class TextBase extends TextBaseCommon { 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.nativeTextViewProtected).textAlignment; + if (this.nativeTextViewProtected instanceof UIButton) { + paragraphStyle.alignment = (this.nativeTextViewProtected).titleLabel.textAlignment; + } else { + paragraphStyle.alignment = (this.nativeTextViewProtected).textAlignment; + } + if (this.nativeTextViewProtected instanceof UILabel) { // make sure a possible previously set line break mode is not lost when line height is specified paragraphStyle.lineBreakMode = this.nativeTextViewProtected.lineBreakMode;