Вы можете использовать delegate
методы UITableviewCell
Вызывается, когда ячейки стали отображаться пользователю.
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
//Set highlighted color here
}
Вызывается, когда ячейки стали исчезать для пользователя.
func tableView(_ tableView: UITableView, didEndDisplaying cell: UITableViewCell, forRowAt indexPath: IndexPath) {
//Set normal color here
}