เปลี่ยนสีพื้นหลัง Table View Cell ต่างจากเปลี่ยนสี Table View ใช้ cell.contentView.backgroundColor
โค้ดใน cellForRowAt
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! TableViewCell
cell.contentView.backgroundColor = UIColor.cyan
return cell
}ผลลัพธ์:
