iphone - CALayer 给每个子层投下阴影,如何去除?

标签 iphone ios cocoa-touch ipad core-animation

我有一个 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/

相关文章:

ios - react native 分支非分支链接始终

ios - iOS bundle 中的 cer 证书 - 危险吗?

ios - 为离线游戏保存玩家详细信息的最佳方式

ios - 如果我插入此函数 -imageFromCurrentFramebufferWithOrientation - (GPUImageLookupFilter),我会收到错误消息

iphone - UIView nextResponder 如何知道 UIViewController 是什么?

iPhone 网络应用程序自动刷新

iphone - 自定义 UITableView 不显示

iphone - :In app purchase and Monotouch 的文档或博客

iphone - 崩溃呈现模态视图 Controller

ios - "Realm accessed from incorrect thread"在收到 HTTP 响应后更改对象