 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to change background color of TableView items on iOS?
Changing the background color of table view items is different from changing the background color of the table view. New programmers may often confuse between these two things, In this post, we will be seeing how to change the background color of TableView items i.e. cells.
So let’s get started.
For changing the background color of the table view cell, you should change the contentView.backgroundColor property of the cell.
Add the below code in your cellForRowAt indexPath method, cell.contentView.backgroundColor = UIColor.cyan
Your method should look like something below,
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 } Now run the project to see the effect.

Advertisements
 