2

I have an UILabel in my UIView. The text of my label is dynamic: it's a web service call which returns to me the text that I will put in my label. Here's an example of the content of the label:

"this is an example of my text/nthis is the second line". 

I would like to put the first line in a specific font (Helvetica-Bold 12px for example) and the second line in another font (Helvetica 15px for example). How i can do this? Thanks for your answers.

Scott Corscadden
  • 2,831
  • 1
  • 25
  • 43
samir
  • 4,501
  • 6
  • 49
  • 76

3 Answers3

3

Honestly I'd recommend using two separate UILabel instances, take your text and get an array via [string componentsSeparatedByString:@"\n"], then place object at index 0 in the first one, and if you have a second object, put it in the second label.

Scott Corscadden
  • 2,831
  • 1
  • 25
  • 43
1

You could go for a static UIWebView and simply wrap your text into HTML+CSS. This will be much easier than doing all the layout in code.

Bartosz Ciechanowski
  • 10,293
  • 5
  • 45
  • 60
1

Maybe what you are looking for is NSAttributedString. Here is a example: iphone/ipad: How exactly use NSAttributedString?

Community
  • 1
  • 1
hburde
  • 1,441
  • 11
  • 6