1

enter image description here

Can anyone explain how to solve that ?

Here is what it shows me now on iPhone X (iOS 12.4)

Here is my code below

@available(iOS 11.0, *)
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
    guard let account = accounts?[indexPath.row] else { return nil }

    getAndSetAmountConstraint(from: account)

    let editAction = UIContextualAction(style: .normal, title: nil) { [weak self] (_, _, completionHandler) in
        self?.showEditAlertViewWith(account: account)
        completionHandler(true)
    }
    let deleteAction = UIContextualAction(style: .normal, title: nil) { [weak self] (_, _, completionHandler) in
        self?.removeRow(at: indexPath)
        completionHandler(true)
    }

    editAction.image = UIImage(named: "edit")
    deleteAction.image = UIImage(named: "delete")
    editAction.backgroundColor = .lightGray
    deleteAction.backgroundColor = .lightGray

    let actions = UISwipeActionsConfiguration(actions: [deleteAction, editAction])
    return actions
}
Majit U.
  • 31
  • 5

1 Answers1

3
    class ImageWithoutRender: UIImage {
    override func withRenderingMode(_ renderingMode: UIImage.RenderingMode) -> UIImage {
        return self
    }
}

@available(iOS 11.0, *)
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
    guard let account = accounts?[indexPath.row] else { return nil }

    getAndSetAmountConstraint(from: account)

    let editAction = UIContextualAction(style: .normal, title: nil) { [weak self] (_, _, completionHandler) in
        self?.showEditAlertViewWith(account: account)
        completionHandler(true)
    }
    let deleteAction = UIContextualAction(style: .normal, title: nil) { [weak self] (_, _, completionHandler) in
        self?.removeRow(at: indexPath)
        completionHandler(true)
    }

    if let cgImageEdit =  UIImage(named: "edit")?.cgImage {
        editAction.image = ImageWithoutRender(cgImage: cgImageEdit, scale: UIScreen.main.nativeScale, orientation: .up)
    }
    
    if let cgImageDelete =  UIImage(named: "delete")?.cgImage {
        deleteAction.image = ImageWithoutRender(cgImage: cgImageDelete, scale: UIScreen.main.nativeScale, orientation: .up)
    }
    editAction.backgroundColor = .lightGray
    deleteAction.backgroundColor = .lightGray

    let actions = UISwipeActionsConfiguration(actions: [deleteAction, editAction])
    return actions
}

TRY THIS