UITableViewCell Background Color is a different shade at left and right edges of cell

350 views Asked by At

I'm setting the background color of a cell in tableview:willDisplayCell and I'm getting the color I want. However, the left and right edges of the cell are a different shade and I'm not sure why. Does anyone have any ideas why the shade of the background color would be different on the edges of the cell? Thanks

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    cell.backgroundColor = [UIColor colorWithRed:.9333333 green:.46666667 blue:.43137225 alpha:0.5];

}
1

There are 1 answers

0
mike On

After a little bit of experimentation and hw731's suggestion to look at my subviews, I found out why I was experiencing this. In the code I shared, you'll notice that I set the alpha to 0.5, because initially this view was going to have a bit of transparency. Doing so allowed the background color of the cell's textLabel to show through a bit on the sides, making it a different shade than the rest of the cell. There were two things I found that could fix it. I could keep the transparency of the cell's background color at 0.5, but to do so I had to also set cell.textLabel.backgroundColor to the desired color. What I ended up doing is just reverting back to an alpha of 1.0 so I didn't have to worry about it. So it looks to me as if the problem was just a matter of subviews showing through since I set my alpha below 1.0. I'm sure someone could explain this better than me, and if so, feel free. Hope this helps someone else!