【发布时间】:2018-01-28 04:04:54
【问题描述】:
使用 Xcode 9.2,在 UITableView 中,当单元格被左滑时,我正在设置一个带有图像但没有文本的按钮。 这是我正在使用的精确代码:
func tableView(_ tableView: UITableView,
editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let myButton = UITableViewRowAction(style: .normal, title: "") {
action, index in
print("myButton was tapped")
}
myButton.backgroundColor = UIColor(patternImage: UIImage(named: "myImage")!)
return [myButton]
}
它可以工作,但图像出现在单元格的底部。
我怎样才能把它带到中心?
以防万一,这是我用于测试的图像(70x70 像素):
这是它在表格视图中的外观:
【问题讨论】:
-
这很奇怪,它确实以我为中心。您能否上传一张图片并展示它的外观以及您的图片使用哪种尺寸?
-
我刚刚编辑了帖子以包含我正在使用的测试图像。
标签: ios swift uitableview uitableviewrowaction