Grouped UITableview remove outer separator line

前端 未结 19 2230
遇见更好的自我
遇见更好的自我 2020-12-02 10:58

I have a grouped UITableview which is created programatically. Also I have a cell with xib file populated in tableview programmatically as well. So far so good. But I want t

19条回答
  •  执念已碎
    2020-12-02 11:46

    Here the solution. This is for static cells. If you want dynamic then just rewrite "count". Hope it helps.

    extension NSObject {
       var theClassName: String {
           return    NSStringFromClass(self.dynamicType).componentsSeparatedByString(".").last!
       }
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        tableView.separatorStyle = .None
    }
    override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
        let count = tableView.numberOfRowsInSection(indexPath.section)
        if ( indexPath.row != count - 1 ) {
            for view in cell.subviews {
                if view.theClassName == "_UITableViewCellSeparatorView" {
                    view.backgroundColor = UIColors.redColor()
                }
            }
        }
    }
    

提交回复
热议问题