UIScrollView and CATiledLayer from scratch

my situation: I created a UIScrollView with a UIView, inside which the Graph class is called, which draws a good graph in context. Now I have found that the phone will not display a UIView if the width exceeds 8192 pixels. In fact, according to Apple docs, if I want it to be larger than 1024 pixels, I have to implement CATiledLayer.

But after reading and searching on Google many times, it’s still hard for me to understand the basics of CATiledLayer for this task - I somehow lost between Quartz vs. Cocoa and levels and sublayers against views and subzones.

Ideally, I would like to leave the Graph class intact, just completely cross out the context, divide it into fragments and scroll through them. Scrollview should simply be scrolled horizontally, without scaling or vertical scrolling. Is it possible? If so, how do I proceed? Perhaps someone can give me a diagram, only some markers or pseudo codes, how should I restructure scrollview, uiview and graph class to use tiling.

Thank you in advance for any response.

+5
source share
1 answer

, , . CATiledLayer . , CATiledLayer , :

CATiledLayer *tiled = [CATiledLayer layer];
[self.view.layer addSublayer:tiled];

, :

MyTLDelegate *myDelegate = [[MyTLDelegate alloc] init];
tiled.delegate = myDelegate;
// I haven't checked if CATiledLayer retains myDelegate, check this!

...
@implementation MyTLDelegate {

-(void)drawLayer:(CATiledLayer *)layer inContext:(CGContextRef)ctx
{
    CGRect dirtyRect = CGContextGetClipBoundingBox(ctx);
    // draw!
}

, , , . Graph, CATiledLayer. 20 , . ( , )

. -, , , , . / .

+4

All Articles