Creating shadows for your layers can easily introduce some offscreen render passes to your app.
The following code will do just that:
But why is this any worse than using something like CoreGraphics?
Well, it turns out that its just a lack of information on the part of the layer. When a layer is trying to create a shadow for text or an image, it has no way of knowing the shape of that content up front. Because of that, it needs to do a render pass ahead of time just to analyze the alpha component of the layer and decide where the shadow should go.
That’s why setting a shadowPath fixes things for an image. Since you provided the path information the layer no longer needs to render the content in memory to figure things out on its own!
ほら、the problem is fiixed!