iOS 9 UITableView separators insets (significant left margin)

后端 未结 11 2122
故里飘歌
故里飘歌 2020-12-02 16:41

I have a problem with separators between UITableViewCells in UITableView on iOS 9. They have the significant left margin. I already ha

11条回答
  •  借酒劲吻你
    2020-12-02 17:26

    Swift 3.0 / 4.0

    tableView.cellLayoutMarginsFollowReadableWidth = false
    
    func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
        if cell.responds(to: #selector(setter: UITableViewCell.separatorInset)) {
            cell.separatorInset = UIEdgeInsets.zero
        }
        if cell.responds(to: #selector(setter: UIView.preservesSuperviewLayoutMargins)) {
            cell.preservesSuperviewLayoutMargins = false
        }
        if cell.responds(to: #selector(setter: UIView.layoutMargins)) {
            cell.layoutMargins = UIEdgeInsets.zero
        }
    }
    

提交回复
热议问题