How to increase the UITableView separator height?

后端 未结 17 2214
花落未央
花落未央 2020-12-08 00:19

I want more space(10px) between each cell. How can I do this?

And I have added this code

tableView.separatorStyle = UITableViewCellSepar         


        
17条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-08 00:47

    For Swift 4

    Implemented King-Wizard's solution to Swift 4:

    public func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
        let additionalSeparatorThickness = CGFloat(4)
    
        let additionalSeparator = UIView(frame: CGRect(x: 0,
                                                       y: cell.frame.size.height - additionalSeparatorThickness, width: cell.frame.size.width, height: additionalSeparatorThickness))
        additionalSeparator.backgroundColor = UIColor.groupTableViewBackground
        cell.addSubview(additionalSeparator)
    
    }
    

提交回复
热议问题