Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CATiledLayer to CALayer

I have a view with a CATiledLayer backing. I want to take the visible tiles from this CATiledLayer UIView and add it to another view as its CALayer backing, thus recreating the visible image in another UIView that doesnt use CATiledLayer.

The reason I want to do this is I will use this second UIView to mask the effect of updating the CATiledLayer backed UIView - this currently produces a flicker as all tiles are re-loaded.

The problem is, I'm not totally sure how i would do this. Any ideas?

like image 580
GWed Avatar asked Jun 18 '12 15:06

GWed


1 Answers

CATiledLayer is a subclass of CALayer providing a way to asynchronously provide tiles of the layer's content, potentially cached at multiple levels of detail.

You can render the visible things in the layer into a CGContextRef with:

- (void)renderInContext:(CGContextRef)ctx

And then use this to update your other layer by settings its delegate and implementing the

- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)context 

ss shown here http://www.raywenderlich.com/2502/introduction-to-calayers-tutorial

But honestly I don't think this is efficient.

like image 63
Pochi Avatar answered Nov 08 '22 23:11

Pochi