【问题标题】:Padding for table view cell表格视图单元格的填充
【发布时间】:2020-09-12 07:38:39
【问题描述】:

我将单元格添加到表格中并使用 xib 制作它们。现在它们是桌子的整个宽度。 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))
    }

【问题讨论】:

  • 您可以在 xib 中添加自动布局约束。

标签: ios swift uitableview cell padding


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-05-19
    • 2014-01-30
    • 1970-01-01
    • 1970-01-01
    • 2017-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多