0

Image

I want to implement a feature in my iphone app that does something similar to this. To have 2 different color fonts in 1 sentence. I read somewhere on stack overflow about three 20, but three 20 won't work on my app. I also read something about textview? but I tried to read the documentation for that, but i didn't really understand.

Anyone have some sample code or any other suggestions??

thanks!

albertamg
  • 28,492
  • 6
  • 64
  • 71
anc1revv
  • 1,563
  • 7
  • 24
  • 42

3 Answers3

1

TTTAttributedLabel is a drop-in replacement for UILabel that will let you have multiple fonts, colors, and styles applied to a single label. All you need to do is pass in an NSAttributedString! It's definitely a lot easier and more performant than loading in something gigantic like Three20 or using a UIWebView.

mattt
  • 19,544
  • 7
  • 73
  • 84
0

Take a look at the NSAttributedString class.

EDIT: There are a few posts on SO that provide some guidance in using this class. One such example can be found here.

Does that help?

Community
  • 1
  • 1
csano
  • 13,266
  • 2
  • 28
  • 45
0

There are a few NSAttributedString OpenSource projects on GitHub that allow this sort of thing.

Before NSAttributed string was available we all used a UIWebView and "styled" HTML to achieve the same affect. This may be an option depending on your final needs.

wuf810
  • 633
  • 12
  • 19