You can use the UITableViewRowAction backgroundColor to set a custom image or view. The trick is to use UIColor(patternImage:) .
Basically, the width of a UITableViewRowAction region is determined by its title, so you can find the exact length of the title (or space) and set the exact size of the image using patternImage .
To implement this, I made a UIView extension to the UIView .
func image() -> UIImage { UIGraphicsBeginImageContextWithOptions(bounds.size, isOpaque, 0) guard let context = UIGraphicsGetCurrentContext() else { return UIImage() } layer.render(in: context) let image = UIGraphicsGetImageFromCurrentImageContext() UIGraphicsEndImageContext() return image! }
and make a line with spaces and exact length,
fileprivate func whitespaceString(font: UIFont = UIFont.systemFont(ofSize: 15), width: CGFloat) -> String { let kPadding: CGFloat = 20 let mutable = NSMutableString(string: "") let attribute = [NSFontAttributeName: font] while mutable.size(attributes: attribute).width < width - (2 * kPadding) { mutable.append(" ") } return mutable as String }
and now you can create a UITableViewRowAction .
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? { let whitespace = whitespaceString(width: kCellActionWidth) let deleteAction = UITableViewRowAction(style: .'default', title: whitespace) { (action, indexPath) in // do whatever you want } // create a color from patter image and set the color as a background color of action let kActionImageSize: CGFloat = 34 let view = UIView(frame: CGRect(x: 0, y: 0, width: kCellActionWidth, height: kCellHeight)) view.backgroundColor = UIColor.white let imageView = UIImageView(frame: CGRect(x: (kCellActionWidth - kActionImageSize) / 2, y: (kCellHeight - kActionImageSize) / 2, width: 34, height: 34)) imageView.image = UIImage(named: "x") view.addSubview(imageView) let image = view.image() deleteAction.backgroundColor = UIColor(patternImage: image) return [deleteAction] }
The result will look like this.

Another way to do this is to import a custom font that has the image you want to use as the font and use UIButton.appearance . However, this will affect other buttons unless you manually set a different font for the button.
In iOS 11, this message will be displayed [TableView] Setting a pattern color as backgroundColor of UITableViewRowAction is no longer supported. It currently works, but it will not work in a future update.