views:

305

answers:

4

Hi,

Is it possible to use the CFAttributedString type to draw formatted text on the iPhone? I see it in the documentation, but I can't figure out how to actually draw it to a context.

Thanks,

Kyle

+1  A: 

Actually, it turns out this is answered in the iPhone documentation, I just didn't read it carefully enough:

iPhone OS Note: While Core Foundation on iPhone OS contains CFAttributedString, there are no additions to the APIs in UIKit to add specific attributes such as font, style, or color, and there are no APIs to draw attributed strings.

There you go, no free formatted text. Bummer.

Kyle

Kyle
+2  A: 

The workaround is to use a WebKitView. Format your text as HTML and display in a mini web view at whatever size you need.

Kailoa Kadano
Yes, unfortunately the refresh speed of a UIWebView is not fast enough for my application.
Kyle
A: 

There's an undocumented method on TextView to pass in HTML formatted text (it's really a kind of web view underneath). A number of apps in the store make use of it, just make sure your app works without it there.

Kendall Helmstetter Gelner
+2  A: 

Three20 has a formatted text field. Basically Joe Hewitt implemented a light HTML interpreter to render the text, so it is much faster than a webview. fast enough to be used in a tableview.

Corey Floyd