I am trying to change the background color of the view that appears when you swipe a UITableViewCell row, the background color behind the 'Delete' button.
I tried changing the cell.editingAccessoryView but that didn't do anything.
UIView* myBackgroundView = [[UIView alloc] initWithFrame:CGRectZero];
myBackgroundView.backgroundColor = [UIColor clearColor];
cell.editingAccessoryView = myBackgroundView;
Any ideas?
I'm answering this because it took me a while to find an answer and this is the first entry that comes up in a search. By using the willDisplayCell
method you can access the cells background color. Note that [UIColor clearColor];
will return white in so adjust your code accordingly.
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
cell.backgroundColor = [UIColor blackColor];
}
You're almost there. The UITableViewCell
class has a backgroundView
property, which is nil
by default. Just create a new UIView
as you've done in your question, then assign that to the backgroundView
property of your cell.
cell.backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
cell.backgroundView.backgroundColor = [UIColor clearColor];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With