UILabel: adjustsFontSizeToFitWidth property
The adjustsFontSizeToFitWidth property determines whether the font size shrinks when the text does not fit.
Value
A boolean.
- Readable and writable.
- The default is
false. true: when the text does not fit, the font size shrinks until it fits or reaches the lower limit set byminimumScaleFactor. If it still does not fit at the lower limit, it is truncated according tolineBreakMode.false: the font size stays the same; text that does not fit is handled according tolineBreakMode.- After shrinking,
fontstill reads as the original font.
Neither the default nor the effect is verified in the simulator.
Examples
js
const label = new UILabel();
label.text = '¥ 1,234,567.89';
label.numberOfLines = 1;
label.adjustsFontSizeToFitWidth = true;
label.minimumScaleFactor = 0.5;Effect: When the text fits, it is shown at the original font size. When it does not, the font size shrinks automatically until the whole line fits, down to at most half the original size. Not verified in the simulator.
Corresponding iOS API
UILabel.adjustsFontSizeToFitWidth.