我有一个 UIView 容器,里面有一个 TableView ,它的单元格包含图像和按钮。
我想在最外面的容器中添加阴影,但当我这样做时,我发现阴影也被添加到所有图像和按钮中。如何只向层本身添加阴影而没有其子层?
代码:
listContainer.layer.shadowColor = [UIColor blackColor].CGColor;
listContainer.layer.shadowOffset = CGSizeMake(3, 0);
listContainer.layer.shadowOpacity = .8;
listContainer.layer.borderColor = [UIColor blackColor].CGColor;
谢谢!
最佳答案
您是否尝试过图层的 shadowPath 属性?
listContainer.layer.shadowPath = [UIBezierPath bezierPathWithRect:listContainer.bounds.CGPath];
关于iphone - CALayer 给每个子层投下阴影,如何去除?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6954833/