CALayer - Shadow causes a performance hit?
self.view.layer.shouldRasterize = YES;
self.view.layer.rasterizationScale = UIScreen.mainScreen.scale;
I was recently having some issues with slow CALayer shadows, and that simple line of code fixed up everything for me!
You should expect a slowdown from adding a shadow. A shadowRadius
of 20 is very high and will be especially slow.
The other key to improve shadow rendering speed: set the shadowPath
property. It can help dramatically.