Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a recommended image size for UIContextualAction icons?

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.

like image 938
Mike Mertsock Avatar asked Nov 29 '22 06:11

Mike Mertsock


1 Answers

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))
    }
like image 164
matt Avatar answered Dec 19 '22 18:12

matt