Illep
Illep

Reputation: 16851

Adding Color to tableview, and cells

I need to be able to change the background color (the view behind the cells) of a UITableView. I tried the following ;

self.tableView.backgroundColor = [UIColor colorWithRed:230.0f/255.0f green:230.0f/255.0f blue:230.0f/255.0f alpha:1.0f];

What hapens here is that the cells also turn to the above color.

1.) I need the cells to be in another color, and the background of the tableView (When the you scroll the view right up, you will see the background of the tableview- the default color of the tableview is white) to be in a different color.

2.) I have successfully colored the cells of my tableview, i have also added a disclosure arrows, but it shows up in a white background as shown in this image. i need it too to have the same color as the cell. I undestand that i have to add a custom disclosure arrows but i don't know how to do it programatically. Can someone help me here ?

Upvotes: 0

Views: 107

Answers (1)

Alexander Theißen
Alexander Theißen

Reputation: 3889

1) From the UITableViewCell documentation:

Note: If you want to change the background color of a cell (by setting the background color of a cell via the backgroundColor property declared by UIView) you must do it in the tableView:willDisplayCell:forRowAtIndexPath: method of the delegate and not in tableView:cellForRowAtIndexPath: of the data source. Changes to the background colors of cells in a group-style table view has an effect in iOS 3.0 that is different than previous versions of the operating system. It now affects the area inside the rounded rectangle instead of the area outside of it.

2) Have you tried setting the background color of cell.accessoryView?

Upvotes: 1

Related Questions