1

I use the following code

  let deleteAction =
   UIContextualAction(style: .normal, title: ""){ (action, sourceView, completionHandler) in

            self.dataManager.items.remove(at: indexPath.row)
            self.itemCardTableView.deleteRows(at: [indexPath], with: .automatic)
            completionHandler(true)
    }

let deleteResize = #imageLiteral(resourceName: "delete72").resizeImage(withSize: CGSize(width: 50, height: 50), scaleMode: .contentAspectFill)
    deleteAction.backgroundColor = UIColor.white
    deleteAction.backgroundColor = UIColor(patternImage: deleteResize!)

image is repeated. This is not what I want

https://i.stack.imgur.com/xUUWY.png

I want is like this

https://i.stack.imgur.com/CV5DX.png

How to fix it

Josh
  • 43
  • 1
  • 1
  • 8

1 Answers1

0

Do not use UIColor(patternImage: deleteResize!), instead use the image property of the UIContextualAction instance.

To get a truly .clear background has been solved here https://stackoverflow.com/a/51939297/5058116, but appears very messy ...

alexjrlewis
  • 2,717
  • 3
  • 24
  • 58