CATiledLayer: Determining levelsOfDetail when in drawLayer
Posted
by Russell Quinn
on Stack Overflow
See other posts from Stack Overflow
or by Russell Quinn
Published on 2010-05-12T10:37:51Z
Indexed on
2010/05/12
10:44 UTC
Read the original article
Hit count: 780
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.
© Stack Overflow or respective owner