diff --git a/packages/core/platforms/ios/src/UIView+NativeScript.h b/packages/core/platforms/ios/src/UIView+NativeScript.h index aae428144..1ee32f0a5 100644 --- a/packages/core/platforms/ios/src/UIView+NativeScript.h +++ b/packages/core/platforms/ios/src/UIView+NativeScript.h @@ -8,6 +8,6 @@ - (void)nativeScriptSetTextDecorationAndTransform:(NSString*)text textDecoration:(NSString*)textDecoration letterSpacing:(CGFloat)letterSpacing lineHeight:(CGFloat)lineHeight; --(void)nativeScriptSetFormattedTextDecorationAndTransform:(NSDictionary*)details; +-(void)nativeScriptSetFormattedTextDecorationAndTransform:(NSDictionary*)details letterSpacing:(CGFloat)letterSpacing lineHeight:(CGFloat)lineHeight; @end diff --git a/packages/core/platforms/ios/src/UIView+NativeScript.m b/packages/core/platforms/ios/src/UIView+NativeScript.m index e811f6d0f..b00e96e7a 100644 --- a/packages/core/platforms/ios/src/UIView+NativeScript.m +++ b/packages/core/platforms/ios/src/UIView+NativeScript.m @@ -75,9 +75,7 @@ } } --(void)nativeScriptSetFormattedTextDecorationAndTransform:(NSDictionary*)details { - CGFloat letterSpacing = [[details valueForKey:@"letterSpacing"] doubleValue]; - CGFloat lineHeight = [[details valueForKey:@"lineHeight"] doubleValue]; +-(void)nativeScriptSetFormattedTextDecorationAndTransform:(NSDictionary*)details letterSpacing:(CGFloat)letterSpacing lineHeight:(CGFloat)lineHeight { NSMutableAttributedString *attrText = [NativeScriptUtils createMutableStringWithDetails:details]; if (letterSpacing != 0) { NSNumber *kern = [NSNumber numberWithDouble:letterSpacing * ((UITextView*)self).font.pointSize]; @@ -89,7 +87,7 @@ if (lineHeight > 0) { NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; - 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/text-base/index.ios.ts b/packages/core/ui/text-base/index.ios.ts index 93fa79b9e..e523f59a3 100644 --- a/packages/core/ui/text-base/index.ios.ts +++ b/packages/core/ui/text-base/index.ios.ts @@ -241,12 +241,14 @@ export class TextBase extends TextBaseCommon { return; } + const letterSpacing = this.style.letterSpacing ? this.style.letterSpacing : 0; + const lineHeight = this.style.lineHeight ? this.style.lineHeight : 0; if (this.formattedText) { - (this.nativeTextViewProtected).nativeScriptSetFormattedTextDecorationAndTransform(this.getFormattedStringDetails(this.formattedText)); + (this.nativeTextViewProtected).nativeScriptSetFormattedTextDecorationAndTransformLetterSpacingLineHeight(this.getFormattedStringDetails(this.formattedText), letterSpacing, lineHeight); } else { // console.log('setTextDecorationAndTransform...') const text = getTransformedText(isNullOrUndefined(this.text) ? '' : `${this.text}`, this.textTransform); - (this.nativeTextViewProtected).nativeScriptSetTextDecorationAndTransformTextDecorationLetterSpacingLineHeight(text, this.style.textDecoration || '', this.style.letterSpacing !== 0 ? this.style.letterSpacing : 0, this.style.lineHeight ? this.style.lineHeight : 0); + (this.nativeTextViewProtected).nativeScriptSetTextDecorationAndTransformTextDecorationLetterSpacingLineHeight(text, this.style.textDecoration || '', letterSpacing, lineHeight); if (!this.style?.color && majorVersion >= 13 && UIColor.labelColor) { this._setColor(UIColor.labelColor); @@ -295,8 +297,6 @@ export class TextBase extends TextBaseCommon { color: span.color ? span.color.ios : null, backgroundColor: backgroundColor ? backgroundColor.ios : null, textDecoration: getClosestPropertyValue(textDecorationProperty, span), - letterSpacing: this.letterSpacing || 0, - lineHeight: this.lineHeight || 0, //this.style?.lineHeight ? this.style.lineHeight : 0, baselineOffset: this.getBaselineOffset(iosFont, span.style.verticalAlignment), index, }; diff --git a/packages/types-ios/src/lib/ios/objc-x86_64/objc!UIKit.d.ts b/packages/types-ios/src/lib/ios/objc-x86_64/objc!UIKit.d.ts index c4f3e368d..c2d690b96 100644 --- a/packages/types-ios/src/lib/ios/objc-x86_64/objc!UIKit.d.ts +++ b/packages/types-ios/src/lib/ios/objc-x86_64/objc!UIKit.d.ts @@ -24018,7 +24018,7 @@ declare class UIView extends UIResponder implements CALayerDelegate, NSCoding, U layoutSubviews(): void; - nativeScriptSetFormattedTextDecorationAndTransform(details: NSDictionary): void; + nativeScriptSetFormattedTextDecorationAndTransformLetterSpacingLineHeight(details: NSDictionary, letterSpacing: number, lineHeight: number): void; nativeScriptSetTextDecorationAndTransformTextDecorationLetterSpacingLineHeight(text: string, textDecoration: string, letterSpacing: number, lineHeight: number): void; diff --git a/packages/types-minimal/src/lib/ios/objc-x86_64/objc!UIKit.d.ts b/packages/types-minimal/src/lib/ios/objc-x86_64/objc!UIKit.d.ts index c4f3e368d..c2d690b96 100644 --- a/packages/types-minimal/src/lib/ios/objc-x86_64/objc!UIKit.d.ts +++ b/packages/types-minimal/src/lib/ios/objc-x86_64/objc!UIKit.d.ts @@ -24018,7 +24018,7 @@ declare class UIView extends UIResponder implements CALayerDelegate, NSCoding, U layoutSubviews(): void; - nativeScriptSetFormattedTextDecorationAndTransform(details: NSDictionary): void; + nativeScriptSetFormattedTextDecorationAndTransformLetterSpacingLineHeight(details: NSDictionary, letterSpacing: number, lineHeight: number): void; nativeScriptSetTextDecorationAndTransformTextDecorationLetterSpacingLineHeight(text: string, textDecoration: string, letterSpacing: number, lineHeight: number): void;