Код ниже работает, но когда я прокручиваю табличное представление несколько раз, граница начинает появляться и для других ячеек. может кто-нибудь предложить решения.
override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
let separator = UILabel(frame: CGRect(x: 15, y: cell.frame.size.height - 1, width: cell.frame.size.width, height: 1))
if indexPath.section == 0 {
if items.count == 4 {
if indexPath.row == 0 {
separator.backgroundColor = UIColor.lightGray()
cell.contentView.addSubview(separator)
}else {
separator.removeFromSuperview()
}
}else {
separator.removeFromSuperview()
}
}else {
separator.removeFromSuperview()
}
}