UITableViewCell 分割线

表格分割线你们懂的,默认并非从最左侧开始的iphone

在ipad中,发现,分割线距离最左和最右侧,都有距离
ide

在iphone中,只有左侧有空隙spa

去掉分割线:设置UITableView的separatorStyle = UITableViewCellSeparatorStyle.None3d

如今想让分割线占满整个屏幕orm

    override func viewDidLoad() {ip

        

        if tableView.respondsToSelector(Selector("setSeparatorInset:")) {it

            tableView.separatorInset = UIEdgeInsetsZeroio

        }event

        if tableView.respondsToSelector(Selector("setLayoutMargins:")) {table

            if #available(iOS 8.0, *) {

                self.tableView.layoutMargins = UIEdgeInsetsZero

            } else {

                // Fallback on earlier versions

            }

        } 

    }

    

    override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {

        

        // Remove seperator inset

        if cell.respondsToSelector("setSeparatorInset:") {

            cell.separatorInset = UIEdgeInsetsZero

        }

        

        // Prevent the cell from inheriting the Table View's margin settings

        if cell.respondsToSelector("setPreservesSuperviewLayoutMargins:") {

            if #available(iOS 8.0, *) {

                cell.preservesSuperviewLayoutMargins = false

            } else {

                // Fallback on earlier versions

            }

        }

        

        // Explictly set your cell's layout margins

        if cell.respondsToSelector("setLayoutMargins:") {

            if #available(iOS 8.0, *) {

                cell.layoutMargins = UIEdgeInsetsZero

            } else {

                // Fallback on earlier versions

            }

        }

    }

相关文章
相关标签/搜索