views:

80

answers:

4

I would like to be able to format a string in a label or textfield so that i can change the font color and size of certain keywords. does anyone know how to do this? is it possible to find the actual physical dimensions of a CharcterSet as well?

A: 

Currently, I think the UITextField or UILabel will not allow you to change some text to be a color and the others to be another color. But you can use the Three 20 Style library to accomplish that

vodkhang
+2  A: 

Craig Hockenberry from Twitteriffic fame will help you out. Stay away from Three20 if you can. I regret using it sadly, I wish it worked a lot better but I have had far to many issue with it.

The answer is FancyLabels. http://furbo.org/2008/10/07/fancy-uilabels/

Download link http://furbo.org/stuff/FancyLabel_1.0.zip

John Ballinger
What is the problems with Three 20? I see a lot people using it, including Facebook iphone app, right?
vodkhang
A: 

Attributed strings (NSAttributedString and CFAttributedStringRef, and their mutable variants) are what is commonly used in OS X. They are available in iOS. However, UIKit really isn't employing them at this time.

CoreGraphics.framework and CoreText.framework will be your friends, if you do not find a suitable 3rd party solution. PDFs or HTML could also be useful in some cases, and displayed easily.

Justin
+1  A: 

If you really want to, then render it on your own using CoreText. Simply build an NSMutableString and pass it to a renderer with just a few lines of code. CoreText is actually quite easy to use. The other option will be to use an UIWebView where you render some styled html. I did a deeper discussion of the problem in a related post, you might want to have a look at it.

I don't know Three 20 in detail. But if others recommend it, it might be worth a look. Besides that it may be way too much power for your purpose and hence might cost too much performance.

Max Seelemann