【问题标题】:Why is editActionsForRowAt returns a lot of images instead of one image?为什么 editActionsForRowAt 返回很多图像而不是一张图像?
【发布时间】:2019-09-19 12:53:44
【问题描述】:

我想向 tableview 单元格添加滑动操作,但是当我添加图像而不是背景颜色时,它会返回很多图像。

这是我正在尝试的:

func tableView(_ tableView: UITableView, editActionsForRowAt: IndexPath) -> [UITableViewRowAction]? {
    let delete = UITableViewRowAction(style: .default, title: "") { action, index in
        print("more button tapped")
    }
    delete.backgroundColor = UIColor(patternImage: circularIcon(with: .red, size: CGSize(width: 50, height: 50), icon: #imageLiteral(resourceName: "trash-alt"))!)

    let edit = UITableViewRowAction(style: .default, title: "") { action, index in
        print("favorite button tapped")
    }
    edit.backgroundColor = UIColor(patternImage: circularIcon(with: UIColor.appColor(.green)!, size: CGSize(width: 50, height: 50), icon: #imageLiteral(resourceName: "pen-1"))!)

    return [delete, edit]
}

【问题讨论】:

    标签: ios swift tableview nsindexpath


    【解决方案1】:

    因为它是从图像中创建一个图案,所以没有正确计算宽度/高度,所以它只是从中创建一个图案。我打赌你可以从这里得到答案: Using buttons/images in tableView:editActionsForRowAt:

    【讨论】:

      猜你喜欢
      • 2013-12-25
      • 1970-01-01
      • 2021-11-30
      • 2022-10-16
      • 2013-08-15
      • 2021-03-19
      • 2018-01-05
      • 2023-04-07
      • 1970-01-01
      相关资源
      最近更新 更多