我正在寻找一种在普通模式下完全删除UITableView中的分隔线的方法.这是在分组中自动完成的,但这也会以难以衡量的方式更改表的尺寸.我已将分隔线颜色设置为colorClear.但这并不能完全解决问题.
当我试图在单元格中绘制自定义背景视图,并且我希望单元格无缝时,保留在其间的一条像素线会导致我出现问题.是否有更优雅的解决方法,然后使用分组视图,然后拉伸它?
如何去除图中所示的线条?我尝试过以下建议,但没有一个对我有用,
这是我当前的代码cellForRowAt:
if (indexPath.row == place_sections[indexPath.section].rows.count - 1) {
cell.separatorInset.left = 1000
//cell.layer.borderWidth = 0
//cell.separatorInset = UIEdgeInsetsMake(0, 160, 0, 160);
}
if (indexPath.row == 0) {
cell.separatorInset.left = 1000
//cell.layer.borderWidth = 0
//cell.separatorInset = UIEdgeInsetsMake(0, 160, 0, 160);
// self.tableview.tableFooterView = UIView(frame: CGRect(x: 0, y: 0, width: self.tableview.frame.width, height: 1))
}
Run Code Online (Sandbox Code Playgroud)
谢谢
我想删除某些 UITableViewCell separators(不是全部)。
我在 UI 中看到它们,但不明白为什么当我打印出子视图层次结构时它们没有被列出?
for view in cell.subviews {
DDLogDebug(String(describing: type(of: view)))
}
Run Code Online (Sandbox Code Playgroud)
这似乎发生在初始视图中。如果我将 UITableView 单元格滚动到远处然后再返回,UITableViewCell 的分隔符会神奇地出现在子视图日志打印输出中。这里发生了什么?
注意: 我只在模拟器上测试过,因为我目前没有 iPhone X。
ios ×3
uitableview ×3
objective-c ×2
swift ×2
cocoa-touch ×1
dropdown ×1
separator ×1
subviews ×1
uikit ×1