iphone - 为 UITableView 添加阴影

标签 iphone objective-c uitableview shadow

我有一个普通的 UITableView(未分组),我想在左侧和右侧添加阴影。

enter image description here

我怎样才能做到这一点?我试过:

[self.tableView.layer setShadowColor:[[UIColor whiteColor] CGColor]];
[self.tableView.layer setShadowOffset:CGSizeMake(0, 0)];
[self.tableView.layer setShadowRadius:5.0];
[self.tableView.layer setShadowOpacity:1];

但它不起作用。

最佳答案

您需要确保 clipsToBoundsmasksToBounds 在 View 和层上分别设置为 NO

self.tableView.clipsToBounds = NO;
self.tableView.layer.masksToBounds = NO;

关于iphone - 为 UITableView 添加阴影,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9012071/

相关文章:

iphone - FbRequest方法后iPhone应用程序崩溃

objective-c - 创建 DOMElement Objective C 的位图

iphone - CGRect 与多个 CGRect 的碰撞

objective-c - OSX NSUserDefaults 不工作

iphone - 触摸时隐藏导航栏和工具栏

iphone - 我怎样才能在 cocos2d 中垂直而不是水平移动这些背景图像?

ios - 同一个 UIViewController 中的两个 UITableView

ios - 获取 UITableViewCell 的当前宽度

ios - 选择单元格时如何获取节标题 View 的标题

android - 如何从数据库中获取海量数据?