Tom Lilletveit
Tom Lilletveit

Reputation: 2002

Wordwrap text in UILabel with "..." appended at end

I´v created a custom Cell for a tableview - that has some labels like the original but in the original when the text in the title label is longer than what fit´s on screen it appends "..." at the end. I´ve tried finding ways of doing it in IB with no luck. Do I have to create my own method to get this functionality on the UILabel?

Upvotes: 0

Views: 588

Answers (3)

Kyle Richter
Kyle Richter

Reputation: 450

The default property for numberOfLines on a UILabel is 1, if you want to support a multiline label you need to specify the number of lines.

Such as:

myLabel.numberOfLines = 2;

You may also need to resize your label to account for the longer text or use a label that will fit the maximum number of lines.

Upvotes: 0

Tom Lilletveit
Tom Lilletveit

Reputation: 2002

Somehow I had managed to have two labels on top of each other and did not notice. SO the Label truncates the tail adding "..." automatically at the end if Line break mode is set to truncate tail. My bad - I guess if I were more experienced with iOS programming I should have known it does this automatically

Upvotes: 0

Prateek Prem
Prateek Prem

Reputation: 1544

You can use my UIExtendedLabel Class From this link(check my ans) UIExtendedLabel

Upvotes: 1

Related Questions