mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
fix(text-base): update text color for ios (#8617)
This commit is contained in:
@ -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 {
|
||||
|
Reference in New Issue
Block a user