gpt4 book ai didi

ios - 如何重叠 UITableViewCells?

转载 作者:技术小花猫 更新时间:2023-10-29 11:16:24 30 4
gpt4 key购买 nike

enter image description here

如果您查看屏幕截图,您会注意到每个 UITableViewCell 从顶部到上方的 tableview 单元格有 20% 的重叠。

有什么方法可以重叠单元格吗?

最佳答案

我从未尝试过,但这种逻辑会奏效。请记住,您不会触摸重叠区域。

1) 将您的 subview 添加到cell.contentView,确保 subview 的高度大于您的tableView 的rowHeight

float overlapHeight  = 10.0;

subView.frame = CGRectMake(0.0, -10.0,
your_subview_width, rowHeight + overlapHeight);

2) 添加这段代码,这样你的单元格就不会剪掉其框架之外的内容

cell.clipsToBounds = NO;
cell.contentView.clipsToBounds = NO;

3) 现在您的单元格将重叠,但单元格的边界周围会有一个剪辑标记。为避免实现 willDisplayCell 委托(delegate)函数

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundColor = [UIColor clearColor];
}

关于ios - 如何重叠 UITableViewCells?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13046762/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com