I have a table view that has alternate colors as background color for cells. In addition to that i have added a disclosure indicator accessory. However, the problem is that the cell background color doesnt seem to apply to the area 'behind' the disclosure indicator. The cell background color seems to truncate before the disclosure indicator appears at the right end of the table cell.
Asked
Active
Viewed 1,894 times
2
-
Is this a custom accessory or one of the built-in accessories? Can you make a screenshot? – Shaggy Frog Aug 25 '09 at 03:21
1 Answers
1
I had a similar problem. This seems to happen because each row in a table is divided into several parts. So merely changing cell.BackgroundColor isn't going to change the entire rows color.
Try something similar to this.. It worked for me:
UITableViewCell *bgView = [[UITableViewCell alloc] initWithFrame:CGRectZero];
bgView.backgroundColor=indexPath.row % 2? [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1]: [UIColor whiteColor];
cell.backgroundView=bgView;

dpigera
- 3,339
- 5
- 39
- 60
-
what does the `% 2?` do for me it does every other row, how can I get all the rows? Is that divide by 2 or something? – Oct 03 '14 at 21:25