@@ -240,6 +240,9 @@ export class Label extends LabelBase {
240
240
) . height ;
241
241
}
242
242
updateVerticalAlignment ( ) {
243
+ if ( ! this . text ) {
244
+ return ;
245
+ }
243
246
const tv = this . nativeTextViewProtected ;
244
247
const inset = this . nativeViewProtected . textContainerInset ;
245
248
const top = layout . toDeviceIndependentPixels ( this . effectivePaddingTop + this . effectiveBorderTopWidth ) ;
@@ -815,6 +818,7 @@ export class Label extends LabelBase {
815
818
816
819
const textViewSize = textView . frame . size ;
817
820
const fixedWidth = textViewSize . width ;
821
+ let changed = false ;
818
822
819
823
const fontSize = this . style . fontSize || 17 ;
820
824
let expectFont : UIFont = ( this . style . fontInternal || Font . default ) . getUIFont ( UIFont . systemFontOfSize ( fontSize ) ) ;
@@ -825,15 +829,20 @@ export class Label extends LabelBase {
825
829
expectFont = expectFont . fontWithSize ( expectFont . pointSize - 1 ) ;
826
830
expectSize = textView . sizeThatFits ( CGSizeMake ( fixedWidth , Number . MAX_SAFE_INTEGER ) ) ;
827
831
textView . font = expectFont ;
832
+ changed = true ;
828
833
}
829
834
}
830
835
else {
831
836
while ( expectSize . height < textViewSize . height ) {
832
837
expectFont = expectFont . fontWithSize ( expectFont . pointSize + 1 ) ;
833
838
expectSize = textView . sizeThatFits ( CGSizeMake ( fixedWidth , Number . MAX_SAFE_INTEGER ) ) ;
834
839
textView . font = expectFont ;
840
+ changed = true ;
835
841
}
836
842
}
843
+ if ( changed ) {
844
+ this . updateVerticalAlignment ( ) ;
845
+ }
837
846
}
838
847
}
839
848
_onSizeChanged ( ) : void {
@@ -850,7 +859,7 @@ export class Label extends LabelBase {
850
859
if ( value && this . text ) {
851
860
this . textViewDidChange ( this . nativeTextViewProtected ) ;
852
861
} else {
853
- this [ fontInternalProperty . setNative ] ( this . style . font ) ;
862
+ this [ fontInternalProperty . setNative ] ( this . style . fontInternal ) ;
854
863
}
855
864
}
856
865
0 commit comments