如何转换 Tableview 单元格中的删除选项

How to transform Delete option in Tableview cell

我使用 post.

转换了 tableview 和 tableview 单元格以从下到上填充单元格

但我也想将滑动转换为删除选项。 详情请参考图片。

可以看到删除选项没有转换为tableview。 任何有用的答案将不胜感激。

viewDidLoad中的第一个反向UITableView

override func viewDidLoad() {
        super.viewDidLoad()
        tableView.transform = CGAffineTransform(scaleX: 1, y: -1)
}

然后反转cellForRowAt中的单元格。

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
            guard let cell = tableView.dequeueReusableCell(withIdentifier: "MyTableViewCell", for: indexPath) as? MyTableViewCell else { fatalError() }

            cell.transform = CGAffineTransform(scaleX: 1, y: -1)
            cell.contentView.transform = CGAffineTransform(scaleX: 1, y: -1)

            return cell
        }
    func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
        let delete = UITableViewRowAction(style: .default, title: nil) { (action, indexPath) in
            // delete item at indexPath
        }

        let label = UILabel(frame: CGRect(origin: CGPoint(x: 0, y: 0), size: CGSize(width: 75, height: tableView.rectForRow(at: indexPath).height)))
        label.numberOfLines = 0
        label.textAlignment = .center
        label.textColor = UIColor.white
        label.backgroundColor = UIColor.red
        label.text = "Delete"
        UIGraphicsBeginImageContextWithOptions(label.bounds.size, false, 0.0)
        label.layer.render(in: UIGraphicsGetCurrentContext()!)
        let image = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()



        if let cgImage = image?.cgImage {
            let rotada3 = UIImage(cgImage: cgImage, scale: image!.scale, orientation: .downMirrored)
            delete.backgroundColor = UIColor(patternImage: rotada3)

        }


        return [delete]
    }

editActionsForRowAt 我做了一个工作来打印带有镜像文本的图像

转换表格视图

tableView.transform = CGAffineTransform(rotationAngle: -(.pi))

然后在单元格内

cell.transform = CGAffineTransform(rotationAngle: .pi)