fix(text-base): update text color for ios (#8617)

This commit is contained in:
dosomder
2020-06-06 23:08:36 +02:00
committed by GitHub
parent faa0181b9c
commit d3549ac115

View File

@ -142,13 +142,7 @@ export class TextBase extends TextBaseCommon {
} }
[colorProperty.setNative](value: Color | UIColor) { [colorProperty.setNative](value: Color | UIColor) {
const color = value instanceof Color ? value.ios : value; const color = value instanceof Color ? value.ios : value;
const nativeView = this.nativeTextViewProtected; this._setColor(color);
if (nativeView instanceof UIButton) {
nativeView.setTitleColorForState(color, UIControlState.Normal);
nativeView.titleLabel.textColor = color;
} else {
nativeView.textColor = color;
}
} }
[fontInternalProperty.getDefault](): UIFont { [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() { setFormattedTextDecorationAndTransform() {
const attrText = this.createNSMutableAttributedString(this.formattedText); const attrText = this.createNSMutableAttributedString(this.formattedText);
// TODO: letterSpacing should be applied per Span. // TODO: letterSpacing should be applied per Span.
@ -339,6 +343,10 @@ export class TextBase extends TextBaseCommon {
this.nativeTextViewProtected.text = source; this.nativeTextViewProtected.text = source;
} }
} }
if (!style.color && majorVersion >= 13 && UIColor.labelColor) {
this._setColor(UIColor.labelColor);
}
} }
createNSMutableAttributedString(formattedString: FormattedString): NSMutableAttributedString { createNSMutableAttributedString(formattedString: FormattedString): NSMutableAttributedString {