gpt4 book ai didi

ios - uitableviewcell 顶部的灰色分隔线

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:04:16 26 4
gpt4 key购买 nike

在过去的几个小时里,我一直在为这个问题苦苦挣扎,但我找不到解决办法……在 UITableView 中,我插入了一个具有所有不同颜色的自定义 UITableViewCells 列表。这些颜色是 UIView 的一部分,它充当 tableviewCell 的 backgroundView 当我初始化 UITableView 时,我设置了

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

但是,在顶部的每个单元格上仍然有一条灰色细线。此行不是来自 textLabel(此标签的框架比实际单元格小),也不是来自包含颜色的 UIView(layer.borderwidth = 0.0f,颜色为 clearColor)。

Tableview with cells

编辑

好的,我发现线条确实来自包含背景颜色的 UIView。然而禁用它们,当我重新排序它们时会导致透明单元格,这是此 UIView 中的 drawRect 使用以下代码绘制 UIView 的结果:

CGContextSetShouldAntialias(UIGraphicsGetCurrentContext(), true);
CGContextFillRect(UIGraphicsGetCurrentContext(), self.bounds);

有人知道解决这个问题的方法吗?

已解决

对我来说很愚蠢,但是单元格没有背景 View ...所以通过在自定义单元格类中添加这两行,问题就解决了!

self.backgroundView = [[UIView alloc] initWithFrame:CGRectZero];
self.backgroundView.backgroundColor = [UIColor whiteColor];

最佳答案

我找到了我的问题的解决方案。通过在 cell 类的 backgroundView 中设置一个 UIView,并用白色背景色填充它,这解决了这个问题。

self.backgroundView = [[UIView alloc] initWithFrame:CGRectZero];self.backgroundView.backgroundColor = [UIColor whiteColor];

关于ios - uitableviewcell 顶部的灰色分隔线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25325010/

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