3
votes

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

1 Answers

1
votes

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.