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 - 相机图像旋转问题

objective-c - 我怎样才能关闭 UIView

c# - 弄清楚如何摆脱 UITableView 单元格中单元格周围的边框

ios - 从 Table View controller 到 Tab Bar Controller

ios - 摆脱 UINavigationBar 右侧的空间

objective-c - 我错过了什么阻止我使用自动布局制作类似 NSStackView 的通用容器?

iOS 检测 UIWebView 中显示的 PDF 中的 URL

c# - 使用由 iOs CCCrypt 函数使用 AES 生成的 C# 解密 base64 字符串

ios - 无法在 iPhone 中获取密码 UItextfield,但在模拟器中可以

ios - 核心数据与 NSFetchedResultsController :Invalid update with with a property in fetchObjects