我知道如何在 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/