Chatar Veer Suthar
Chatar Veer Suthar

Reputation: 15639

How can I the change text color of the cells of a UITableView?

I have added some data in UITableView, and I want to change the color of the text displayed in the cells.

Is there a delegate method for doing this, or any other way?

Upvotes: 16

Views: 22994

Answers (3)

Bhavisha Khatri
Bhavisha Khatri

Reputation: 11

The code according to hex number of color code

Use this code

If color code is: #4B4B4B so Red:75 Green:75 Blue:75

cell.textLabel.textColor = 
             [UIColor colorWithRed:75.0/255.0 green:75.0/255.0 blue:75.0/255.0 alpha:1];

Upvotes: 1

Ishu
Ishu

Reputation: 12787

You can add labels in the cell and set the color for these labels according to you .And also you can add more than one label and customize the cell.

simply use this line

cellLabel.textColor=[UIColor redColor]; //according to you.

Upvotes: 22

shannoga
shannoga

Reputation: 19869

NO need for Labels

You just need to code :

cell.textLabel.textColor = [UIColor redColor];

or if you want to change the detailTextLabel :

cell.detailTextLabel.textColor = [UIColor blueColor];

good luck

Upvotes: 37

Related Questions