New in iOS 11, UIContextualAction provides a convenient way to implement swipe actions on UITableView cells, with a title and/or image icon.
I haven't found any mention in the Human Interface Guidelines of the image used by UIContextualAction. Does any information exist that defines a standard size or other design guidance for this icon image?
I tried to figure this out by testing a few image sizes to see if iOS would scale it to a consistent size, but it seems to just display whatever you give it with no scaling or cropping, so that didn't provide any clues.
I use 30 by 30. You can render your image down to that size in code easily enough.
let d = UIContextualAction(style: .destructive, title: nil) {
action, view, completion in
// ... whatever ...
completion(true)
}
d.image = UIGraphicsImageRenderer(size: CGSize(width: 30, height: 30)).image { _ in
UIImage(named: "trash")?.draw(in: CGRect(x: 0, y: 0, width: 30, height: 30))
}