0

I am working on an Iphone application. Is there a way to have multiple colors in the same label or TextView?

What i mean is that I need something like this:

enter image description here

Is there a way to do this without using 3 labels? Because the text might change dynamically and I want to have correct positionning.

Thank you

Youssef
  • 9,032
  • 35
  • 118
  • 192

3 Answers3

1

Yes, It's possible to have different style and color in single Label. Have a look at OHAttributedLabel

Also, look at this StackOverFlow Answer.

Community
  • 1
  • 1
Hemang
  • 25,740
  • 17
  • 113
  • 171
1

You can use OHAttributedLabel or CoreTextAttributedLabel

Hemang
  • 25,740
  • 17
  • 113
  • 171
Romit M.
  • 858
  • 10
  • 27
1

In iOS 6 there is a new type of string called NSAttributedString.

You can change colors, fonts, sizes, underline, and almost everything for parts of a string.

Apple Docs

Hemang
  • 25,740
  • 17
  • 113
  • 171
Fogmeister
  • 70,181
  • 37
  • 189
  • 274