I've got a UIView container with a table view in it, whose cells contain images and buttons.
I want to add a shadow to the outter-most container but when I do, I found shadows are also added to all the images and buttons. How can I only add shadow to the layer itself without its sublayers?
code:
listContainer.layer.shadowColor = [UIColor blackColor].CGColor;
listContainer.layer.shadowOffset = CGSizeMake(3, 0);
listContainer.layer.shadowOpacity = .8;
listContainer.layer.borderColor = [UIColor blackColor].CGColor;
Thanks!
Have you tried the shadowPath property of your layer?
listContainer.layer.shadowPath = [UIBezierPath bezierPathWithRect:listContainer.bounds.CGPath];
I had this problem once and the issue was that the layers background color was transparent.
So if you have a UIView, or CALayer, and you are trying to set shadows on it, make sure that there is a background color to prevent shadows from being applied to the sublayers.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With