
- iOS Tutorial
- iOS - Home
- iOS - Getting Started
- iOS - Environment Setup
- iOS - Objective-C Basics
- iOS - First iPhone Application
- iOS - Actions and Outlets
- iOS - Delegates
- iOS - UI Elements
- iOS - Accelerometer
- iOS - Universal Applications
- iOS - Camera Management
- iOS - Location Handling
- iOS - SQLite Database
- iOS - Sending Email
- iOS - Audio & Video
- iOS - File Handling
- iOS - Accessing Maps
- iOS - In-App Purchase
- iOS - iAd Integration
- iOS - GameKit
- iOS - Storyboards
- iOS - Auto Layouts
- iOS - Twitter & Facebook
- iOS - Memory Management
- iOS - Application Debugging
- iOS Useful Resources
- iOS - Quick Guide
- iOS - Useful Resources
- iOS - Discussion
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.
- Related Articles
- How to change the background color of ListView items on Android?
- How to change the background color of ListView items on Android Kotlin?
- How to change the background color of ListView items on Android using Kotlin?
- How do you animate the change of background color of a view on iOS?
- How to change the background color of UIStackView?
- How to set background color of a View in iOS App?
- How to change the font and color on the UITextView in iOS?
- How to create NSIndexPath for TableView in iOS?
- How to animate a change in background color using jQuery on mouseover?
- How to change background-color on a specific wider viewport in CSS ?
- How can I change the text color of the Navigation Bar on iOS?
- How to change the background color using jQuery?
- How to change JFrame background color in Java
- How to change axes background color in Matplotlib?
- How to Change the Background Color of a Div on Mouse Move Over using JavaScript?

Advertisements