【问题标题】:Adding space between tableviewcell in Swift在 Swift 中的 tableviewcell 之间添加空间
【发布时间】:2016-01-19 14:20:24
【问题描述】:

我正在尝试在动态单元格之间添加空间。

这是我的代码。我不明白为什么它不起作用。

 func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 50
    }
 func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        let footer = UIView()
        footer.backgroundColor = UIColor.clearColor()
        return footer
    }

【问题讨论】:

标签: ios swift uitableview


【解决方案1】:

您可以通过将部分中的 numberOfRows 设置为 1 并将 numberofSections 设置为填充单元格的动态项数组来实现此目的。然后,您可以将页脚视图高度设置为您想要的空间。

func tableView(tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
    return YOUR_DESIRED_SPACE_BETWEEN_CELLS
}

【讨论】:

    猜你喜欢
    • 2022-11-11
    • 1970-01-01
    • 2013-07-12
    • 2018-06-15
    • 1970-01-01
    • 2015-10-15
    • 2017-06-06
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多