Search code examples
iosswiftxcodecell

Change color of the drag/move Knob in reorderable tableView


I have a tableView in editing-Mode for reordering Cells. I want to customize the color of the Knob for dragging the Cell. Actually, it is light grey. To understand what the picture is showing: I have a Cell with a height of 70, and a uiview with a height of 60 in it because I want more Space between the Cells. That's why you see the grey parts of the knob (yellow arrows). These I want to have in the same Background color as the tableView itself.

Maybe someone knows how I achieve this?

Ugly TableViewCell


Solution

  • Ok... Got it. Using the Code from here Change Reorder Control's color in table view cell i modified it in this way:

    func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
        for subViewA in cell.subviews {
            if (subViewA.classForCoder.description() == "UITableViewCellReorderControl") {
                subViewA.backgroundColor = UIColor(red:0.89, green:0.00, blue:0.45, alpha:1.0)
                break;
            }
        }
    }
    

    Now it looks like i want:

    Nice looking