IOS AutoLayout Automatic Layout Intermediate Development tutorial (4)-label text automatically adapts to size, width

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.