There are a couple of similar questions out there (e.g. my previous iOS10 variant), but I think there should be up an up to date answer for iOS 11, using Swift4, that doesn't use private APIs, and doesn't rely on you restricting your icon to the unicode emoji.
With the evolution in APIs to iOS11, we can now put image and text, but they are forced into template mode and reverse colored with whatever backgroundColor you set. E.g.
let rename = UIContextualAction(style: .normal, title: "Rename") { (_, view, _) in
self.renameEntry(indexPath)
}
rename.backgroundColor = UIColor.black
rename.image = UIImage(named: "pencilEdit")
let locate = UIContextualAction(style: .normal, title: "Locate") { (_, view, _) in
self.locateEntry(indexPath)
}
locate.backgroundColor = UIColor.blue
locate.image = UIImage(named: "locatePin")
let delete = UIContextualAction(style: .destructive, title: "Forget") { (_, view, _) in
self.deleteEntry(indexPath)
}
delete.backgroundColor = UIColor.red
delete.image = UIImage(named: "triggerDeleteSelector")
return UISwipeActionsConfiguration(actions: [rename, locate, delete])
which produces this:
So apparently, we can have image OR text, but not both.
But the look I want is
Aside from the backwards order, I'm at a loss how to trick the system like I was able to for iOS10. I can still generate an image with both text AND image, but I cannot control the color of that image. Setting backgroundColor to nil or .clear just makes empty squares.