ios - 带阴影的 UITableView

标签 ios objective-c uitableview

我知道如何在 UIViews 周围添加阴影,甚至在 View bounds 更改时为它们设置动画。然而,我遇到了一个看起来有点棘手的观点。 UITableView

在这个 View 周围添加阴影很容易,甚至可以通过这个例子来实现:Adding drop shadow to UITableView 它运作良好。但是我的问题是我需要阴影绕过 UITableView 中的最后一个 cell 而不是它的 bounds。因此,顶部、侧面和底部将是 UITableView 中的最后一个单元格。

考虑到它的工作原理,我相信有更好的解决方案。也许我能够根据单元格的数量调整 UitableView 的框架?然而,细胞是动态的,直到运行时我才知道它们的高度。

如有任何建议,我们将不胜感激。

谢谢!

最佳答案

有点像...

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
  if (indexPath.row == [self tableView:tableView numberOfRowsInSection:indexPath.section] - 1) {
    // last row
    cell.layer.shadowOpacity = 0.5;
    cell.layer.shadowPath = [UIBezierPath bezierPathWithRect:cell.bounds].CGPath;
    cell.layer.masksToBounds = NO;
  }
}

关于ios - 带阴影的 UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33415143/

相关文章:

ios - 如何使用 .automatic DropProposal int iOS 11 区分用户意图

ios - WKWebView在催化剂上没有上下文菜单

objective-c语法问题

ios - 如何透明化表格 View 的边框颜色?

iphone - 线程与异步调用

ios - 为什么在这段代码中我会得到 "Unexpected non-void return value in void function"

iphone - Facebook 安装的参数不返回数据

ios - ios 中的电子邮件和密码验证

iphone - 将 subview 添加到单元格 contentView

ios - 在代码中调整自定义单元格中的标签大小