I'm working with a tableView where the cells have insets and rounded corners. I want to apply the same style to the row actions. Since the customising options are kind of limited (background, style and title), is there a way to do that?

That's my code for the actions:
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
let removeSignal = UITableViewRowAction(style: .destructive, title: translate(.delete)) { (_, indexPath) in
self.removeSignal(atIndex: indexPath.row)
}
return [removeSignal]
}
If you have iOS 11, you can use trailingSwipeActionsConfigurationForRowAt delegate to customise your row action:
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
let deleteAction = UIContextualAction(style: .destructive, title: "Delete") { (action, sourceView, completionHandler) in
print("index path of delete: \(indexPath)")
completionHandler(true)
}
let swipeConfig = UISwipeActionsConfiguration(actions: [deleteAction])
return swipeConfig
}
You can set your customised text in place of "Delete" inside UIContextualAction(style: .destructive, title: "Delete")
You can customise more with these properties of UIContextualAction:
deleteAction.backgroundColor = UIColor.red
deleteAction.image = UIImage(named: "delete")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With