टेबल व्यू आइटम का बैकग्राउंड कलर बदलना टेबल व्यू के बैकग्राउंड कलर को बदलने से अलग है। नए प्रोग्रामर अक्सर इन दो चीजों के बीच भ्रमित हो सकते हैं, इस पोस्ट में, हम देखेंगे कि टेबल व्यू आइटम्स यानी सेल का बैकग्राउंड कलर कैसे बदला जाता है।
तो चलिए शुरू करते हैं।
टेबल व्यू सेल का बैकग्राउंड कलर बदलने के लिए, आपको सेल के कंटेंट व्यू.बैकग्राउंड कलर प्रॉपर्टी को बदलना चाहिए।
Add the below code in your cellForRowAt indexPath method, cell.contentView.backgroundColor = UIColor.cyan
आपका तरीका कुछ नीचे जैसा दिखना चाहिए,
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! TableViewCell
cell.contentView.backgroundColor = UIColor.cyan
return cell
} अब प्रभाव देखने के लिए प्रोजेक्ट चलाएँ।
