iOS multiline label in Interface builder

How can I make a multiline UILabel in interface builder for iOS? I tried the UITextView but it didn't quite suit my needs.

How can I add multiline (text) in label?


You can use numberOfLines property which defines maximum number of lines a label can have. By default, it's 1. Setting it to 0 means the label will have unlimited lines.

You can do it in code:

textLabel.numberOfLines = 5 // for example

Or in Interface Builder:


Hit Control+Enter to add a line in UILabel in Interface Builder/Storyboard.


Thanks AppleVijay!

Also to call sizeToFit, like this:

label.lineBreakMode = UILineBreakModeWordWrap;
label.numberOfLines = 0;
[label sizeToFit];

The height will be automatically computed.


set width of label as u needed small then use IB to set line breaks to word wrap

or use with code like this

I found a solution.

One just has to add the following code:

textLabel.lineBreakMode = NSLineBreakByWordWrapping;
textLabel.numberOfLines = 0;

Set number of lines zero for dynamic text information, it will be useful when your text are varying.

Programatically (Swift 3)

var label = UILabel()
let stringValue = "iOS\nmultiline\nlabel\nin\nInterface\nbuilder"
label.text = stringValue
label.numberOfLines = 0 // Set 0, if number of lines not specified.
label.lineBreakMode = .byTruncatingTail // or .byWrappingWord
label.minimumScaleFactor = 0.8 . // It is not required but nice to have a minimum scale factor to fit text into label frame

Using Inetrface Builder

enter image description here

Note: It is not required to set Minimum Font Scale, but nice to have a minimum scale factor to fit text into label frame.