I have a UIView subclass MyTextView that I add to a scrollView, and it just has a bunch of text, but it gets to be really long sometimes (around 50,000 px high). Using regular drawing methods such as NSString's drawInRect method is apparently not the right way to do this, so now I’m looking into CATiledLayer to help me out with drawing the text. Unfortunately, there’s not enough examples out there to help with drawing text with CATiledLayer, and I’m wondering if anyone knows how I can get started with this task.
Is using CATiledLayer my best option when it comes to drawing really long text in a UIScrollView?
(I don’t want to use a UITextView since that’s also scrollable – and even if I were to use it, I wouldn’t want it to be scrollable, I’d set its frame to 50,000 px high, and that doesn’t solve my problem (remember that I’ll be adding this view to a scrollView, so a UITextView in a scrollView isn’t exactly fun)).
Any ideas?
I don’t know it CATiledLayer is the best but to get you started, you can draw the text content of each tile yourself.
Create the layer and set the delegate:
Then just to normal CGContext drawing code:
you can get the tile rect and/or scale for drawing
A word from the documentation on setting the layer delegate: