Homam
Homam

Reputation: 568

ios 6 UITableViewCell delete button has background color

i have custom UITableViewCell with background pattern

using this method

- (void)tableView:(UITableView *)tableView willDisplayCell:(homeCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

    cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.png"]];
}

and the result was good,

ImageLink: link

but when i swipe to delete, the delete button comes with background color overriding the content of the cell

ImageLink: link

i followed some solutions that i found here in stackoverflow, but none solved my problem

i've tried clearing background color of the delete button using this code

- (void)tableView:(UITableView *)tableView willDisplayCell:(homeCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{

    // create uiview
    UIView* myBackgroundView            = [[UIView alloc] initWithFrame:CGRectZero];
    myBackgroundView.backgroundColor    = [UIColor clearColor];

    // assign the uiview
    cell.editingAccessoryView   = myBackgroundView;
    cell.backgroundView         = myBackgroundView;

    // my background patter
    cell.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"CellBG.png"]];
}

but the result was not good, the whole cell background was with no background color

ImageLink: link

how to display delete button with no background color? please help


some of the solutions i tried: link 1

link 2

link 3

Upvotes: 1

Views: 1256

Answers (1)

danypata
danypata

Reputation: 10175

The problem is not from the delete button background, the problem is that when the delete button is shown, your UITableViewCell content view size is decreased. By adding the labels from IB they are added to the contentView.

What I did in my other projects (I didn't use autolayout) I set the springs and struts so that the labels size will be re sized when the UITableView cell will be re sized.

Upvotes: 1

Related Questions