table 视图单元格的填充

Padding for table view cell

我将单元格添加到 table 并使用 xib 制作它们。现在它们是 table 的全宽。 How can I add indentation on the right and left for these cells? 我尝试了以下代码,但没有帮助。

override func awakeFromNib() {
        super.awakeFromNib()
        contentView.frame = frame.inset(by: UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10))
    }

在单元格内创建一个子视图,将其约束到超级视图,即单元格,然后将现有的子视图添加到这个新添加的视图中。还有其他方法,这是我多年来发现的最简单的方法。