Evgeniy Kleban Evgeniy Kleban - 1 year ago 102
iOS Question

Force UILabel to display 2 lines

I have UILabel that display single line if it have space for it.

However, i need to force it always display 2 lines, even if there is enough space for display it in 1 line.

Robust way is to reduce right spacing constraint and check that condition on all of available devices, but maybe there is an easier way?

To be clear, i want this:enter image description here

look like this: enter image description here

As i mentioned, now labels binded to superview by constraints.

Answer Source

In InterfaceBuilder settings of UILabel text press option+enter between "Справочник" and "МКБ".

Or set label.text = @"Справочник\nМКБ";.

And, of course, set yourLabel.numberOfLines = 2; (or 0) in IB or code.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download