Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write multiple lines in a label

I have a XIB file of type View XIB. In it I have a View controller, and in the View controller I have a label.
I have long text that I want to break, but it doesn't - it gets truncated.
I tried this solution - I did it in the attribute window - but it doesn't help.

like image 538
Lea Cohen Avatar asked Oct 14 '10 09:10

Lea Cohen


People also ask

Can you display multiple lines of text in a label?

Select the Text widget and look to the properties palette. You'll then be able to change it to multi line.

How do you show multiple lines of text?

Click the Display tab. To enable multiple lines of text to be typed in the text box, select the Multi-line check box, and then optionally do one of the following: To prevent users from being able to insert paragraph breaks in the text box by pressing ENTER, clear the Paragraph breaks check box.

What is multiple lines of text?

a : consisting of multiple lines of text a multiline headline : capable of showing, containing, or processing multiple lines of text a multiline display/field New multiline optical character readers are already being put in place; they can read an entire address and spray forth a bar code that stands for a nine-digit ...


1 Answers

use this

myLabel.lineBreakMode = UILineBreakModeWordWrap;

if you are worried about backwards compatibility use this because the comand i mentioned before was introduced in iOS 6.0

myLabel.numberOfLines = 0;
like image 102
Samueljt Avatar answered Oct 24 '22 13:10

Samueljt