iOS 9 UITableView separators insets (significant left margin)

后端 未结 11 2149
故里飘歌
故里飘歌 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:30

    Swift 2.2 iOS 9.3

    In viewDidLoad

    tableView.cellLayoutMarginsFollowReadableWidth = false
    

    In UITableViewDelegates

    func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
        if cell.respondsToSelector(Selector("setSeparatorInset:")){
            cell.separatorInset = UIEdgeInsetsZero
        }
        if cell.respondsToSelector(Selector("setPreservesSuperviewLayoutMargins:")) {
            cell.preservesSuperviewLayoutMargins = false
        }
        if cell.respondsToSelector(Selector("setLayoutMargins:")){
            cell.layoutMargins = UIEdgeInsetsZero
        }
    }
    

提交回复
热议问题