mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-14 01:43:14 +08:00
fix(ios): properties lineHeight and letterSpacing did not apply to spans (#10025)
This commit is contained in:

committed by
GitHub

parent
1ad8099cd8
commit
e4b5cdf7df
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
(<any>this.nativeTextViewProtected).nativeScriptSetFormattedTextDecorationAndTransform(this.getFormattedStringDetails(this.formattedText));
|
||||
(<any>this.nativeTextViewProtected).nativeScriptSetFormattedTextDecorationAndTransformLetterSpacingLineHeight(this.getFormattedStringDetails(this.formattedText), letterSpacing, lineHeight);
|
||||
} else {
|
||||
// console.log('setTextDecorationAndTransform...')
|
||||
const text = getTransformedText(isNullOrUndefined(this.text) ? '' : `${this.text}`, this.textTransform);
|
||||
(<any>this.nativeTextViewProtected).nativeScriptSetTextDecorationAndTransformTextDecorationLetterSpacingLineHeight(text, this.style.textDecoration || '', this.style.letterSpacing !== 0 ? this.style.letterSpacing : 0, this.style.lineHeight ? this.style.lineHeight : 0);
|
||||
(<any>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,
|
||||
};
|
||||
|
@ -24018,7 +24018,7 @@ declare class UIView extends UIResponder implements CALayerDelegate, NSCoding, U
|
||||
|
||||
layoutSubviews(): void;
|
||||
|
||||
nativeScriptSetFormattedTextDecorationAndTransform(details: NSDictionary<any, any>): void;
|
||||
nativeScriptSetFormattedTextDecorationAndTransformLetterSpacingLineHeight(details: NSDictionary<any, any>, letterSpacing: number, lineHeight: number): void;
|
||||
|
||||
nativeScriptSetTextDecorationAndTransformTextDecorationLetterSpacingLineHeight(text: string, textDecoration: string, letterSpacing: number, lineHeight: number): void;
|
||||
|
||||
|
@ -24018,7 +24018,7 @@ declare class UIView extends UIResponder implements CALayerDelegate, NSCoding, U
|
||||
|
||||
layoutSubviews(): void;
|
||||
|
||||
nativeScriptSetFormattedTextDecorationAndTransform(details: NSDictionary<any, any>): void;
|
||||
nativeScriptSetFormattedTextDecorationAndTransformLetterSpacingLineHeight(details: NSDictionary<any, any>, letterSpacing: number, lineHeight: number): void;
|
||||
|
||||
nativeScriptSetTextDecorationAndTransformTextDecorationLetterSpacingLineHeight(text: string, textDecoration: string, letterSpacing: number, lineHeight: number): void;
|
||||
|
||||
|
Reference in New Issue
Block a user