Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> iOS

วิธีเปลี่ยนสีพื้นหลัง TableView Cell ใน iOS

เปลี่ยนสีพื้นหลัง 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
}

ผลลัพธ์:

วิธีเปลี่ยนสีพื้นหลัง TableView Cell ใน iOS