How to create automatic line break with Uilabel

Asked

Viewed 1,140 times

3

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 the content, depending on whether the user post a very extensive containing the View hides part of the content due to the view size, put a UIScrollView, but a question has arisen of how to make the Label create automatic line breaks and how to increase the size of the ScrollView.

Could someone help me with that?

inserir a descrição da imagem aqui

  • If you set the property Lines from the label to 0 within the storyboard it automatically assumes the amount of lines needed for your text.

2 answers

2

An alternative is to use textView, it already has its own scroll. For texts with multiple lines it is more suitable than a label. If you want to use Uilabel with scrollView, regarding line breaking, you can also do this by storyboard. You can increase the number of lines by "Lines", and to break the line, change the "Line break".

storyboard

1

Scroll is just Voce add constrain to it, then it will adapt to all sizes! was that?

On the line breaking, if you look at the properties, you can see how many lines you want the Uilabel and also put contractions in it, Oce is sure you want to use a Uilabel for content?

label.numberOfLines = 3;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.