I have set background colors for all my UITableViewCells. However, when I click my UIBarButtonItem "edit", the delete and the draggable icons distort the background color, making white background behind them. Is there any way around this? I can show code if necessary, but this seems like a pretty straightforward question.
The background color of a table cell is usually set like this:
cell.backgroundView.backgroundColor = [UIColor redColor];
This works fine. However, when an object of class UITableViewCell is created, by default it does not have a backgroundView, it is nil. The developer needs to create the backgroundView when needed. So depending on the particular situation you need to do something like:
if (cell.backgroundView == nil) {
cell.backgroundView = [[[UIView alloc] init] autorelease];
}
cell.backgroundView.backgroundColor = [UIColor redColor];
This is the default behavior of the uitableviewcells
in the editing mode. Try setting the background color for your tableViewCells again in
- (void)setEditing:(BOOL)editing animated:(BOOL)animate
{
if(editing)
{
// set background color
}
else {
}
If needed, try setting your background color as your property so that you can set it up here.
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