Skip to content

Commit 0afb433

Browse files
committed
fix(ios): some autoFontSize fixes
1 parent 36e7070 commit 0afb433

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/label.ios.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ export class Label extends LabelBase {
240240
).height;
241241
}
242242
updateVerticalAlignment() {
243+
if (!this.text) {
244+
return;
245+
}
243246
const tv = this.nativeTextViewProtected;
244247
const inset = this.nativeViewProtected.textContainerInset;
245248
const top = layout.toDeviceIndependentPixels(this.effectivePaddingTop + this.effectiveBorderTopWidth);
@@ -815,6 +818,7 @@ export class Label extends LabelBase {
815818

816819
const textViewSize = textView.frame.size;
817820
const fixedWidth = textViewSize.width;
821+
let changed = false;
818822

819823
const fontSize = this.style.fontSize || 17;
820824
let expectFont: UIFont = (this.style.fontInternal || Font.default).getUIFont(UIFont.systemFontOfSize(fontSize));
@@ -825,15 +829,20 @@ export class Label extends LabelBase {
825829
expectFont = expectFont.fontWithSize(expectFont.pointSize - 1);
826830
expectSize = textView.sizeThatFits(CGSizeMake(fixedWidth, Number.MAX_SAFE_INTEGER));
827831
textView.font = expectFont;
832+
changed = true;
828833
}
829834
}
830835
else {
831836
while (expectSize.height < textViewSize.height) {
832837
expectFont = expectFont.fontWithSize(expectFont.pointSize + 1);
833838
expectSize = textView.sizeThatFits(CGSizeMake(fixedWidth, Number.MAX_SAFE_INTEGER));
834839
textView.font = expectFont;
840+
changed = true;
835841
}
836842
}
843+
if (changed) {
844+
this.updateVerticalAlignment();
845+
}
837846
}
838847
}
839848
_onSizeChanged(): void {
@@ -850,7 +859,7 @@ export class Label extends LabelBase {
850859
if (value && this.text) {
851860
this.textViewDidChange(this.nativeTextViewProtected);
852861
} else {
853-
this[fontInternalProperty.setNative](this.style.font);
862+
this[fontInternalProperty.setNative](this.style.fontInternal);
854863
}
855864
}
856865

0 commit comments

Comments
 (0)