Вы можете установить цвет фона для ячеек в разделе:
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier:"YOUR_CELL") as! UITableViewCell
switch indexPath.section {
case 0:
cell.backgroundColor = UIColor.blue
case 1:
cell.backgroundColor = UIColor.yellow
case 2:
cell.backgroundColor = UIColor.green
default:
cell.backgroundColor = UIColor.clear
}
return cell
}
Но если ячейка пуста, вам придется вернуть пустую ячейку, которая отображает только backgroundColor.
Нет выделенной функции, в которой вы можете указать backGroundColor для каждого раздела.