UITableView with Checkmark and Custom Accessory Button

521 views Asked by At

I am implementing a UITableView with a checkmark on the left of the label and a custom accessoryView with a button on the right side. The checkmarks are selected and deselected in didSelectRowAt(indexPath). The custom button for the accessoryView is implemented as follows:

let button = UIButton(type: .custom)
button.setImage(UIImage(named: "arrow-right-light.png")?.maskWithColor(color: .white), for: .normal)
button.sizeToFit()
button.addTarget(self, action: #selector(buttonTest), for: .touchUpInside)
button.tag = indexPath.row
cell.accessoryView = button

However, there is a small area on the corner right of the table view (indicated in image below) that still responds to didSelectRowAt(indexPath).

Area between button and tableView edge that still responds to didSelectRowAt(indexPath)

Does anyone have any suggestions on how I can have the button snap to the rightMargin of the tablewView programmatically? I want the user to be able to hit the area from the button till the edge of the table without selecting the checkmark (indicated in image below):

expected button selection area

Thank you.

0

There are 0 answers