I have a view that’s rendering a PDF into a CATiledLayer. This is working well.
Now I’m attempting to add a drop shadow to the view, so I did the usual:
tiledLayer.masksToBounds = NO;
tiledLayer.shadowOffset = CGSizeMake(5, 5);
tiledLayer.shadowRadius = 5;
tiledLayer.shadowOpacity = 0.5;
tiledLayer.shadowPath = [UIBezierPath bezierPathWithRect:self.bounds].CGPath;
But what I’m seeing rendered is incorrect. What seems to be happening is that there’s a drop shadow drawn for each tile as the tiles are being drawn. Once all the tiles are drawn, the final product looks right and has a shadow in the right place, but the intermediate rendering is distracting.
How can I use a drop shadow with a CATiledLayer?
You should wrap your CATiledLayer in a container layer with those shadow attributes applied to it. Judging by the
self.boundscall, you might already be embedding the CATiledLayer in a view’s layer, in which case (unless you needmasksToBounds) you can just apply the shadow attributes to that layer directly.