diff --git a/packages/core/platforms/ios/src/UIView+NativeScript.m b/packages/core/platforms/ios/src/UIView+NativeScript.m index bc2fb2123..f288aeaa5 100644 --- a/packages/core/platforms/ios/src/UIView+NativeScript.m +++ b/packages/core/platforms/ios/src/UIView+NativeScript.m @@ -26,8 +26,7 @@ BOOL isTextView = [self isKindOfClass:[UITextView class]]; if (lineHeight > 0) { NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; - // Note: Avoid using lineSpacing as it will append the height as extra space - paragraphStyle.minimumLineHeight = lineHeight; + paragraphStyle.lineSpacing = lineHeight; // make sure a possible previously set text alignment setting is not lost when line height is specified if ([self isKindOfClass:[UIButton class]]) { paragraphStyle.alignment = ((UIButton*)self).titleLabel.textAlignment; @@ -89,8 +88,7 @@ BOOL isLabel = [self isKindOfClass:[UILabel class]]; if (lineHeight > 0) { NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; - // Note: Avoid using lineSpacing as it will append the height as extra space - paragraphStyle.minimumLineHeight = lineHeight; + paragraphStyle.lineSpacing = lineHeight; // make sure a possible previously set text alignment setting is not lost when line height is specified if ([self isKindOfClass:[UIButton class]]) { paragraphStyle.alignment = ((UIButton*)self).titleLabel.textAlignment; diff --git a/packages/core/ui/styling/style-properties.d.ts b/packages/core/ui/styling/style-properties.d.ts index ab19aac51..61f99e3d0 100644 --- a/packages/core/ui/styling/style-properties.d.ts +++ b/packages/core/ui/styling/style-properties.d.ts @@ -77,6 +77,7 @@ export const minWidthProperty: CssProperty; export const widthProperty: CssAnimationProperty; export const heightProperty: CssAnimationProperty; +export const lineHeightProperty: CssProperty; export const marginProperty: ShorthandProperty; export const marginLeftProperty: CssProperty; export const marginRightProperty: CssProperty; diff --git a/packages/core/ui/text-base/index.android.ts b/packages/core/ui/text-base/index.android.ts index 955be17d6..cb538617b 100644 --- a/packages/core/ui/text-base/index.android.ts +++ b/packages/core/ui/text-base/index.android.ts @@ -374,20 +374,10 @@ export class TextBase extends TextBaseCommon { } [lineHeightProperty.getDefault](): number { - return this.nativeTextViewProtected.getLineHeight() / layout.getDisplayDensity(); + return this.nativeTextViewProtected.getLineSpacingExtra() / layout.getDisplayDensity(); } [lineHeightProperty.setNative](value: number) { - const dpValue = value * layout.getDisplayDensity(); - - if (SDK_VERSION >= 28) { - this.nativeTextViewProtected.setLineHeight(dpValue); - } else { - const fontHeight = this.nativeTextViewProtected.getPaint().getFontMetricsInt(null); - // Actual line spacing is the diff of line height and font height - const lineSpacing = Math.max(dpValue - fontHeight, 0); - - this.nativeTextViewProtected.setLineSpacing(lineSpacing, 1); - } + this.nativeTextViewProtected.setLineSpacing(value * layout.getDisplayDensity(), 1); } [fontInternalProperty.getDefault](): android.graphics.Typeface {