有几个类似的问题(例如我之前的 iOS10 变体),但我认为应该有一个针对 iOS 11 的最新答案,使用 Swift4,不使用私有 API,也不依赖于您将图标限制为 unicode 表情符号。
随着 API 向 iOS11 的发展,我们现在可以放置图像和文本,但它们被迫进入模板模式,并使用您设置的任何背景颜色反转颜色。例如
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") …Run Code Online (Sandbox Code Playgroud) uitableview ios ios11 uiswipeactionsconfiguration uicontextualaction
iOS 11中的新增功能,UIContextualAction提供了一种方便的方法,可通过标题和/或图像图标在UITableView单元格上实现滑动操作。
在人机接口指南中,我没有发现UIContextualAction使用的图像。是否存在任何定义此图标图像的标准尺寸或其他设计指南的信息?
我试图通过测试一些图像大小来弄清楚这一点,以查看iOS是否可以将其缩放到一致的大小,但是它似乎只是显示您提供的任何内容而没有缩放或裁剪,因此没有提供任何线索。
你如何为 中的标题设置自定义字体UIContextualAction?
我试过了,UIAppearance但没有任何运气......
干杯! :)
uitableview ios uitableviewrowaction uiswipeactionsconfiguration uicontextualaction