From d3549ac115ecd39967790eaca2ea85bb1b291bbc Mon Sep 17 00:00:00 2001 From: dosomder Date: Sat, 6 Jun 2020 23:08:36 +0200 Subject: [PATCH] fix(text-base): update text color for ios (#8617) --- .../ui/text-base/text-base.ios.ts | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/nativescript-core/ui/text-base/text-base.ios.ts b/nativescript-core/ui/text-base/text-base.ios.ts index fa36b9f8a..45689d4fa 100644 --- a/nativescript-core/ui/text-base/text-base.ios.ts +++ b/nativescript-core/ui/text-base/text-base.ios.ts @@ -142,13 +142,7 @@ export class TextBase extends TextBaseCommon { } [colorProperty.setNative](value: Color | UIColor) { const color = value instanceof Color ? value.ios : value; - const nativeView = this.nativeTextViewProtected; - if (nativeView instanceof UIButton) { - nativeView.setTitleColorForState(color, UIControlState.Normal); - nativeView.titleLabel.textColor = color; - } else { - nativeView.textColor = color; - } + this._setColor(color); } [fontInternalProperty.getDefault](): UIFont { @@ -221,6 +215,16 @@ export class TextBase extends TextBaseCommon { } } + _setColor(color: UIColor): void { + const nativeView = this.nativeTextViewProtected; + if (nativeView instanceof UIButton) { + nativeView.setTitleColorForState(color, UIControlState.Normal); + nativeView.titleLabel.textColor = color; + } else { + nativeView.textColor = color; + } + } + setFormattedTextDecorationAndTransform() { const attrText = this.createNSMutableAttributedString(this.formattedText); // TODO: letterSpacing should be applied per Span. @@ -339,6 +343,10 @@ export class TextBase extends TextBaseCommon { this.nativeTextViewProtected.text = source; } } + + if (!style.color && majorVersion >= 13 && UIColor.labelColor) { + this._setColor(UIColor.labelColor); + } } createNSMutableAttributedString(formattedString: FormattedString): NSMutableAttributedString {