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.