Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

rossipoo

macrumors regular
Original poster
Jun 7, 2009
109
0
I have an application that makes extensive use of the CATextLayer class. The iPhone does not seem to have the class available however, which seems at least somewhat ridiculous.

Is the solution to implement my own? That seems like quite a bit of work, I do need it to work with attributed strings.
 
There are no attributed strings either.

I don't have any good advice for you other than ask this question at the Apple iPhone forum where some of the apple people might have a suggestion.
 
How can so many iPhone apps exist with no proper string support. I could live without the attributed string, but I need something I can insert into a CALayer tree, and I need to be able to pick a font and size.

Is subclassing CALayer and writing this myself really the only thing I can do?
 
Apple considers that UIWebView and html is the way to display styled text. It does work in many cases.

If you only need to draw a single line of text then that's easy enough using the UIStringDrawing methods. If you need wrapped multiline text then you'll have to use those methods to do the text layout and it won't be simple. I haven't yet needed to do this.

UILabel and UITextView work well for display of single style text, but they work at the view level. I haven't done much at the layer level so I can't give you good advice on that.

Another thought. There might be a way that you can get a screenshot of a UILabel saved into a CGImage and then add that to a CALayer instead of the actual text. If you only need a single line of text then it's not hard at all to draw text into an image. I think to get the "screenshot" you can use [label.layer renderInContext:]
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.