Remove separator line for only one cell

后端 未结 13 2245
萌比男神i
萌比男神i 2020-12-30 19:38

I\'m trying to remove the separator for one UITableViewCell. I did the following:

- (UITableViewCell *)tableView:(UITableView *)tableView cellFo         


        
13条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-30 19:59

    If you want to hide the separation line for only a specific type of cell, you can use the following code:

     override func layoutSubviews() {
        super.layoutSubviews()
        subviews.forEach { (view) in
            if view.dynamicType.description() == "_UITableViewCellSeparatorView" {
                view.hidden = true
            }
        }
    }
    

    Write this code in the cell (it must be a subclass of UITableViewCell) for which you do not want a separation line to appear.

提交回复
热议问题