Advertisement
Guest User

Untitled

a guest
May 19th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? {
  2.  
  3. //Compartir
  4. let shareAction = UITableViewRowAction(style: .default, title: "Compartir") { (action, indexPath) in
  5.  
  6. let shareDefaultText = "Estoy mirando la receta de \(self.recipes[indexPath.row].name!) en la App de David Fraj Blesa"
  7.  
  8. let activityController = UIActivityViewController(activityItems: [shareDefaultText, self.recipes[indexPath.row].image!], applicationActivities: nil)
  9. self.present(activityController, animated: true, completion: nil)
  10. }
  11.  
  12. shareAction.backgroundColor = UIColor(red: 30.0/255.0, green: 164.0/255.0, blue: 253.0/255.0, alpha: 1.0)
  13.  
  14. //Borrar
  15. let deleteAction = UITableViewRowAction(style: .default, title: "Borrar") { (action, indexPath) in
  16. self.recipes.remove(at: indexPath.row)
  17. self.tableView.deleteRows(at: [indexPath], with: .fade)
  18. }
  19.  
  20. deleteAction.backgroundColor = UIColor(red: 202.0/255.0, green: 202.0/255.0, blue: 202.0/255.0, alpha: 1.0)
  21.  
  22. return [shareAction, deleteAction]
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement