I am developing an iPad application.
In my application users can move, rotate and scale images.
I’ve noticed that when I add a 3d shadowed border to the images, it makes them incredibly heavy and unresponsive. I add the border using this code:
self.layer.MasksToBounds = false;
self.layer.ShadowColor = [[UIColor alloc] initWithRed:0 green:0 blue:0 alpha:0.5].CGColor;
self.layer.ShadowOpacity = 1.0f;
self.layer.ShadowOffset = CGSizeMake(0, 2.5f);
Why does this happen? What ways do I have to solve this?
This is a well known problem with CALayer shadows. Set the
shadowPathproperty as well and you will see a good performance boost.The shadow path can just be a path of the bounds of your image view. You should be able to just set it once and the layer transforms will keep it up to date as your image is scaled etc.