删除 UITableViewCell 上不需要的左缩进

Removing undesired left indent on UITableViewCell

我的主 UIViewController 中有一个 Table 视图,它有一个 non-editable 原型单元格。我正在尝试从 table 视图单元格中删除左缩进。无论我用什么方法,缩进都不会消失。

这是我试过的:

我还在代码中尝试了以下内容:

myTable.layoutMargins = UIEdgeInsets.zero
myTable.separatorInset = UIEdgeInsets.zero

而这个在 cellForRowAt:indexPath

里面
cell.indentationLevel = 0
cell.indentationWidth = 0
cell.layoutMargins = UIEdgeInsets.zero
return cell

这是正在发生的事情的屏幕截图:

我需要所有 "Hello's" 到 left-align 的红色部分 header 文本。

如何删除内容的left-indent?

谢谢。

试试这个 -

helloLabel.textAlignment = .Left
cell.addSubview(helloLabel)

您是否尝试过使用带有标签并与左边缘保持所需距离的自定义单元格?

我确定 layoutMargins 是 UITableViewCell 缩进的原因。但我认为你不能改变 layoutMargins。我几乎不使用 UITableViewCell 的 textLabel。可以参考Setting layoutMargins of UIView doesn't work