Skip to content

Instantly share code, notes, and snippets.

@ppamorim
Created February 20, 2020 19:30
Show Gist options
  • Save ppamorim/ee4b78405b2b48392d7c1a686be0e461 to your computer and use it in GitHub Desktop.
Save ppamorim/ee4b78405b2b48392d7c1a686be0e461 to your computer and use it in GitHub Desktop.
@available(iOS 13.0, *)
func tableView(_ tableView: UITableView, contextMenuConfigurationForRowAt indexPath: IndexPath, point: CGPoint) -> UIContextMenuConfiguration? {
let actionProvider: UIContextMenuActionProvider = { _ in
let confirmDelete: UIMenu = UIMenu(title: "something".localized, options: [UIMenu.Options.destructive], children: [
UIAction(title: "delete".localized, attributes: [.destructive]) { [weak self] _ in
//.....
},
UIAction(title: "cancel".localized) { _ in }
])
return UIMenu(
title: "options".localized,
children: [confirmDelete])
}
return UIContextMenuConfiguration(
identifier: "SomeOptions" as NSCopying,
previewProvider: nil,
actionProvider: actionProvider)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment