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 w开发者_StackOverflowon'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!
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.
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?
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.
精彩评论