I am showing list of items in a UITableView in which only the first row will have separator and the rest of the rows won't have any separators. For the rest of the cell I added:
cell.separatorInset = UIEdgeInsets(top: 0, left: cell.bounds.size.width, bottom: 0, right: 0)
which should remove separators all the rows except first row. But when the app is launched all the cells except the first cell loaded have partial separators like this:
on scrolling when the bottom rows are loaded the don't have this issue:
when I scroll all the first loaded rows out of screen and the scroll back to them all the partial separators are gone:
I can't seem to find a fix for this issue. Is there any other way I can make the separators disappear by setting their color same as background color?? My xcode version is 11.7 and swift language version 5.
Update 1
As requested func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell looks like:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = countryCodeView.dequeueReusableCell(withIdentifier: "CountryCell") as! CountryCell
let country = countries[indexPath.row]
cell.flag.text = country.flag
cell.countryCode.text = "+\(country.countryCode)"
cell.countryName.text = country.name
if indexPath.row == 0 {
cell.countryCode.font = UIFont(name: "ProximaNovaA-Bold", size: 16)
cell.countryName.font = UIFont(name: "ProximaNovaA-Bold", size: 16)
cell.separatorInset = UIEdgeInsets(top: 16, left: 16, bottom: 16, right: 16)
cell.tickIcon.isHidden = false
} else {
cell.countryCode.font = UIFont(name: "ProximaNovaA-Regular", size: 16)
cell.countryName.font = UIFont(name: "ProximaNovaA-Regular", size: 16)
cell.separatorInset = UIEdgeInsets(top: 0, left: cell.bounds.size.width, bottom: 0, right: 0)
cell.tickIcon.isHidden = true
}
return cell
}