Possible Duplicate:
Drawing shadow with Quartz is slow on iPhone & iPad. Another way?
I created the below helper method to add a shadow to my UIImageViews. It looks good, but I noticed that it slows down the graphics rendering significantly and it looks especially bad when you rotate the device. I also get an occasional Received memory warning.
- (void)addShadowToImageView:(UIImageView *)imageView;
{
imageView.layer.shadowColor = [UIColor lightGrayColor].CGColor;
imageView.layer.shadowOffset = CGSizeMake(0, 1);
imageView.layer.shadowOpacity = 1;
imageView.layer.shadowRadius = 1.0;
imageView.clipsToBounds = NO;
}
How can I optimize this effect for performance?
I would check out this post:
Drawing shadow with Quartz is slow on iPhone & iPad. Another way?
The gist of it is that you should be using CALayer’s shadowPath property, as this is how CoreGraphics is able to optimize shadows. In fact, if you check the docs for this property, you’ll see the bit
As a general rule, directly manipulating the layer of a UIView (doing things like shadows or corner radii) tends to slow performance significantly.