Core animations are designed with performance considerations. First, it is hierarchical presentation and is designed to run on small devices (iPhone and itouch). These devices have limited memory and the CPU and GPU are not as powerful as those on the desktop, the core animation is designed to be more efficient, but it does not mean you can use it in your code.
Shadow is also costly. Because their attributes are partial transparent layers, it requires a lot of computing to determine each pixel (because each pixel needs to be calculated until there is an opaque layer encountered. If the shadows overlap, the consumption will increase. Consider limiting only the shadow of the outermost layer and allowing the inner layer not to produce any shadow.
Quartzcore layer. Shadow performance. They need to re-render, and every new change will causeSlide, lag, lag.
Http://stackoverflow.com/questions/10133109/fastest-way-to-do-shadows-on-ios/10133182#10133182
Adding a shadowpath shoshould give you a huge performance boost. The following example assumes you only want the shadow on the sides of your view
CGPathRef path = [UIBezierPath bezierPathWithRect:view.bounds].CGPath;[view.layer setShadowPath:path];
Edit: On default a calayer draws a shadow during animations, the following code allows you to cache the shadow as a bitmap and reuse it instead
Redrawing it:
self.view.layer.shouldRasterize = YES;// Don't forget the rasterization scale// I spent days trying to figure out why retina display assets weren't working as expectedself.view.layer.rasterizationScale = [UIScreen mainScreen].scale;
Another answer is:
You can greatly improve the performance of a calayer's shadow by using itsshadowPath
Property-this
Allows it to draw the shadow without having to recalculate the Alpha mask of the layer. For a rectangular view, you 'd use it like this:
theView.layer.shadowPath = [UIBezierPath bezierPathWithRect:theView.bounds].CGPath;
Or, if its corners are rounded,
theView.layer.shadowPath = [UIBezierPath bezierPathWithRoundedRect:theView.bounds cornerRadius:theView.layer.cornerRadius].CGPath;
Improve performance based on actual conditions!