anc1revv
anc1revv

Reputation: 1623

Having multiple color fonts in one sentence in xcode/iphone

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!

Upvotes: 0

Views: 2500

Answers (3)

mattt
mattt

Reputation: 19544

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.

Upvotes: 1

wuf810
wuf810

Reputation: 643

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.

Upvotes: 0

csano
csano

Reputation: 13696

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?

Upvotes: 0

Related Questions