IOS AutoLayout Automatic Layout Intermediate Development tutorial (4)-label text automatically adapts to size, width
2015-01-24 00:30
When compared to people will often encounter the label or TextField display text view, display incomplete, or can not automatically change the length, automatically change the font settings:
Today, let's show you how to get the label to fit a different width in AutoLayout:
1. Automatically change the font:
First set the label's constraints, including the width of the height, by default, your label is unchanged, but when you encounter more text, there will be an incomplete display problem:
, we set the width and height of the label, and other constraints, fixed the label,
This is the number of words we added to the label ... There will be a problem with the display not complete:
So how can this be solved? In fact, only need to set up, let the font automatically smaller to display more words in the same width:
Setup methods such as:
Check the label and view the property bar on the right.
Click AutoShrink
Choose Minimum Font Scale or Minimum font Size to configure a smaller font or a minimum scaling scale to solve the problem!
Look at the settings after the effect is:
2. Method One effect is good, but the font is smaller! Can the font be small, the word increase, the width of the label automatically become longer?
The Setup method is simple,
Just change the width of the label to >=:
Such as:
You can then see the effect, and the label automatically gets longer if the font is not changed!
IOS AutoLayout Automatic Layout Intermediate Development tutorial (4)-label text automatically adapts to size, width