Henson Fang
Henson Fang

Reputation: 1207

How to change the editing style of UITableView?

From the below picture, I want to change the color of multiple selection buttons and the background color while selected(the blue part).

The editingStyle is defined below

-(UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return UITableViewCellEditingStyleDelete|UITableViewCellEditingStyleInsert;
}

I tried to set tintColor of the tableView,the color of multiple selection buttons changed but the background color doesn't change.

enter image description here

Upvotes: 0

Views: 766

Answers (1)

ovo
ovo

Reputation: 2172

You need to change the tintColor and multipleSelectionBackgroundView for each cell.

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    //...

    cell.tintColor = UIColor.orange

    let bgview = UIView()
    bgview.backgroundColor = UIColor.purple
    cell.multipleSelectionBackgroundView = bgview

    //...
}

sample

Upvotes: 1

Related Questions