views:

453

answers:

1

I have a CATiledLayer inside a UIScrollView and all is working fine. Now I want to add support for showing different tiles for three levels of zooming.

I have set levelsOfDetail to 3 and my tile size is 300 x 300. This means I need to provide three sets of tiles (I'm supplying PNGs) to cover: 300 x 300, 600 x 600 and 1200 x 1200.

My problem is that inside "(void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx" I cannot work out which levelOfDetail is currently being drawn. I can retrieve the bounds currently required by using CGContextGetClipBoundingBox and usually this requests a rect for one of the above sizes, but at layer edges the tiles are usually smaller and therefore this isn't a good method.

Basically, if I have set levelsOfDetail to 3, how do I find out if drawLayer is requesting level 1, 2 or 3 when it's called?

Thanks,

Russell.

+2  A: 

I worked this out eventually.

Get the CTM fom the graphics context and look at its scale (e.g. the a element).

    CGAffineTransform transform = CGContextGetCTM (ctx);

    transform.a holds the zoom
Russell Quinn
Hi Russell,I am using CATiledLayer to draw pages from a pdf.It is working fine but when i rotates the device in console logs i am getting 3 errors ,1.wait_fences: failed to receive reply: 100040032.<Error>: FT_Select_Charmap failed: error 6.3.Received memory warning. Level=2Do you have any idea about how to resolve these errors.Thank you
chaitanya