0

I've a string as follows:

#define BEEF_LABLE @"Recommended Internal Temp 145 - Medium Rare 160 - Medium 170 - Well done"

I want to display it in a 4 lines label. "Recommended Internal Temp" in one line, "145 - Medium Rare" in 2nd line, "160 - Medium" in 3rd line and "170 - Well done" in 4th line.

How can I split the text accordingly.

Satyam
  • 15,493
  • 31
  • 131
  • 244

1 Answers1

4
yourLabel.lineBreakMode = UILineBreakModeWordWrap;
yourLabel.numberOfLines = 0;  

and add ("\n") in the String accordingly... like this

#define BEEF_LABLE @"Recommended Internal Temp \n 145 - Medium Rare 160 \n- Medium \n 170 - Well done"
Aravindhan
  • 15,608
  • 10
  • 56
  • 71
  • +1 I usually use \r\n to break up the lines. Just \n does the trick? Also, setting `youLabel.numberOfLines = 0;` is how to tell the UILabel to have any number of lines. Trisha I'm sure knows this, but I'm adding it to this comment because it is not obvious that that is what that line is doing. Might also consider looking at [Multiple lines of text in UILabel](http://stackoverflow.com/q/990221/590956). – Sam Oct 20 '11 at 14:15