How to give space between two cells in tableview?

前端 未结 26 1525
谎友^
谎友^ 2020-11-29 00:11

I want a space between two cell in table view,

I want cell like this,

\"enter<

26条回答
  •  悲&欢浪女
    2020-11-29 00:55

    Here is my method with Swift 3:

    In ViewDidLoad(), add:

    self.tableView.rowHeight = 500.0
    

    In tableview "CellForRowAt", add following:

    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    
        let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
    
        // Configure the cell...
        var actualContentView = UIView()
        actualContentView.frame = CGRect(x: 10, y: 10, width: cell.contentView.frame.width - 20, height: cell.contentView.frame.height - 20)
        actualContentView.backgroundColor = UIColor.blue
        cell.contentView.addSubview(actualContentView)
    
        return cell
    }
    

提交回复
热议问题