Skip to content

Commit 691d460

Browse files
authored
fix(ios): another edge case for text as NSAttributedString
1 parent 04de923 commit 691d460

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/label/index.ios.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,10 @@ export class Label extends LabelBase {
252252
return result.height;
253253
}
254254

255+
useNSAttributedString() {
256+
return this.formattedText || this.html || (this.text instanceof NSAttributedString)
257+
}
258+
255259
updateVerticalAlignment(applyVerticalTextAlignment = true) {
256260
const nativeView = this.nativeTextViewProtected;
257261
if (!this.mCanUpdateVerticalAlignment) {
@@ -407,7 +411,7 @@ export class Label extends LabelBase {
407411
// if (this.isUsingNSTextView) {
408412
// desiredSize.height += nativeView.textContainerInset.top + nativeView.textContainerInset.bottom;
409413
// }
410-
if (resetFont && !this.formattedText && !this.html) {
414+
if (resetFont && this.useNSAttributedString()) {
411415
nativeView.font = resetFont;
412416
}
413417

@@ -653,7 +657,7 @@ export class Label extends LabelBase {
653657
const nativeView = this.nativeTextViewProtected;
654658
const newFont: UIFont = value instanceof Font ? value.getUIFont(nativeView.font) : value;
655659
nativeView.font = newFont;
656-
if (this.formattedText || this.html) {
660+
if (this.useNSAttributedString()) {
657661
this._setNativeText();
658662
}
659663
}
@@ -877,7 +881,7 @@ export class Label extends LabelBase {
877881
let expectSize;
878882

879883
const stepSize = this.autoFontSizeStep || 2;
880-
const changeFont = !(this.formattedText || this.html || this.text instanceof NSAttributedString);
884+
const changeFont = !this.useNSAttributedString();
881885
const updateFontSize = (font) => {
882886
if (!changeFont) {
883887
NSLabelUtils.updateFontRatioRatio(textView, font.pointSize / fontSize);

0 commit comments

Comments
 (0)