UIContextualAction 图标是否有推荐的图像大小? [英] Is there a recommended image size for UIContextualAction icons?
问题描述
iOS 11 中的新功能,UIContextualAction 提供了一种在UITableView 单元格,带有标题和/或图像图标.
New in iOS 11, UIContextualAction provides a convenient way to implement swipe actions on UITableView cells, with a title and/or image icon.
我在人机界面指南中没有发现 UIContextualAction 使用的图像的任何提及.是否存在定义此图标图像的标准尺寸或其他设计指南的信息?
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?
我试图通过测试一些图像大小来解决这个问题,看看 iOS 是否会将它缩放到一致的大小,但它似乎只显示你给它的任何东西,没有缩放或裁剪,所以没有提供任何线索.
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.
推荐答案
我使用 30 x 30.你可以很容易地在代码中将图像渲染到那个大小.
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))
}
这篇关于UIContextualAction 图标是否有推荐的图像大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!