elson
elson

Reputation: 53

How to add linebreaks in iPhone programming?

I need to know how to add a linebreak in plain text such as UILabel.

Soli...there is an amendment at here....

The linebreaks will added on the plain text on SMS or any notification alert message.

So, the "escape sequence" can used as well ?

Thanks

Upvotes: 1

Views: 304

Answers (3)

Marco Mustapic
Marco Mustapic

Reputation: 3859

set the property numberOfLines of the label to 0. Then,

yourlabel.text = @"Line 1\nLine2";

will display as:

Line 1
Line 2

Upvotes: 3

Gordon Wilson
Gordon Wilson

Reputation: 26384

The escape sequence "\n" adds a newline.

@"Line one\nLine two" will display as

Line one
Line two

Upvotes: 1

Thomas Müller
Thomas Müller

Reputation: 15635

I haven't tried this, and I'm not sure if it'll display properly, but have you tried putting \n in your NSString?

myLabel.text = @"First Line\nSecond Line";

Upvotes: 0

Related Questions