1

enter image description here I want to add swipe actions to tableview cell, but when I added an image instead of background color it return a lot of images.

Here is what I am trying:

func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? {
    let delete = UITableViewRowAction(style: .default, title: "") { action, index in
        print("more button tapped")
    }
    delete.backgroundColor = UIColor(patternImage: circularIcon(with: .red, size: CGSize(width: 50, height: 50), icon: #imageLiteral(resourceName: "trash-alt"))!)

    let edit = UITableViewRowAction(style: .default, title: "") { action, index in
        print("favorite button tapped")
    }
    edit.backgroundColor = UIColor(patternImage: circularIcon(with: UIColor.appColor(.green)!, size: CGSize(width: 50, height: 50), icon: #imageLiteral(resourceName: "pen-1"))!)

    return [delete, edit]
}
marcolz
  • 2,880
  • 2
  • 23
  • 28

1 Answers1

0

Because it's creating a pattern from the image, that is not taking width/height calculations properly, so it's just creating a pattern from it. I bet you can get an answer from here: Using buttons/images in tableView:editActionsForRowAt:

ChillY
  • 106
  • 6