views:

413

answers:

2

I have a CATiledLayer that is used to display a PDF page (this CATiledLayer is the layer type of my UIView which is a subview of a UIScrollView). I want to add overlay markers on this page. So I add a sublayer to my CATiledLayer. This sublayer again hosts the different marker's layers and acts as a grouping layer.

So graphically, I have: (keep in mind that I have multiple markers which are CALayers also, this is ascii art after all)

pdf page (CATiledLayer)
----------------------
|  CALayer           |
|  +---------+       |
|  |  +----+ |       |
|  |  |mker| |       |
|  |  +----+ |       |
|  +---------+       |
|                    |
----------------------

I have set up the canonical drawLayer:inContext: in my view for drawing the pdf.

When I zoom to have more detail, the pdf gets rendered correctly, but the markers get scaled. No matter what I do to the bounds of the CALayer, my markers always become bigger and appear jagged.

I would like to have the markers always the same size, as when they were initialized and first shown when the view was drawn. Is this possible ? or am I using a wrong approach ? Should I do special drawing for my contained CALayer in the drawLAyer:inContext: message ?

As you see, there are things that I am missing to resolve my problem. Thank you for any help you provide.

+1  A: 

The marker is scaling because it inherits the transforms of the superlayer. Create another top level CALayer that contains the markers and other objects you don't want scaled and overlay it on top of CATiledLayer.

hyn
I finally ended up using another uiview that contain the markers. I beleive it has the same effect. I gather that it is not possible to override the transform inheritance. Thanks for the response.
David
A: 

Hello David,

I am trying to do something similar to you, but without the overlay. (i.e. draw PDF within a CATiledLayer). Are you able to share some sample implementation code?

belsokar