How to create automatic line wrap with UILabel

Posted on

Question :

I’m creating an app for posting catholic content, but I’m having a problem, I have a UIViewController with a title, an image of the post and below the image of the content, depending on whether the user posts a very extensive containing a View hides part of the content because of the size of the view, I put a UIScrollView , but there was a question about how to make the Label create automatic line breaks and how to increase the dimension of ScrollView .

Could anyone help me with this?


Answer :

An alternative is to use the textView, it already has its own scroll. For multiline text it is more suitable than a label.
If you want to use UILabel with scrollView, regarding the line breaks, you can also do this through the storyboard. You can increase the number of lines by “Lines”, and to break the line, change the “Line break”.


Scroll is only you add constrain to it, there it will adapt to all sizes! was it?

On the line break, if you look at the properties, you can see how many lines you want UILabel and also put contrains in it, are you sure you want to use a UILabel for content?

label.numberOfLines = 3;


Leave a Reply

Your email address will not be published. Required fields are marked *