IOS development-use storyboard to achieve the adaptive height of UILabel (iOS8), storyboarduilabel

Source: Internet
Author: User

IOS development-use storyboard to achieve the adaptive height of UILabel (iOS8), storyboarduilabel

I haven't written a blog for a long time. Writing more blogs in the future is an improvement for myself and a help for everyone.

Recently, I was particularly obsessed with storyboard and xib visual programming. When I was writing a project, I encountered a problem: how to make UILabel highly adaptive and I checked a lot of articles and blogs. There is no good way to do this, I did it manually to achieve the desired effect. I will share it below.

I believe everyone will encounter this situation. The label does not adapt to the height based on the number of words in the text.

So how can we make UILabel adaptive height?

This is what we need to do in visual programming.

1. You cannot set the label height to a fixed value. The label size is determined by setting it to a fixed value.


2. Set the label attribute to these values. I don't quite understand the specific meaning. I will tell you in the following blog


The final result is as follows:

We can see that we have achieved the desired effect.

Here I didn't use a line of code to implement the UILabel adaptive height, and this is implemented under the iOS8 condition. It will be somewhat different under iOS7, and storyboard is fast to use, but I don't understand the principles of the code, so the use of code is the premise of using storyboard, so I will use the code in the next blog to achieve a highly adaptive UILabel.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.