Slide to delete with similar design to iOS 10+ Notifications slide to delete in UITableViewCell


Slide to delete with similar design to iOS 10+ Notifications slide to delete in UITableViewCell



How can I make a tableviewcell's slide to delete look like the slide to delete for iOS notifications (fade in and don't touch edge of the screen). I will only have the delete button so I don't need multiple buttons. I would like it to delete upon a full swipe just like the notifications.



Here's a photo of the wanted result with 2 buttons (I only want 1):



iOS notification swipe to delete



The current code I have written only sets the editing style to delete. I have tried using UIContextualAction but I believe I can only set the style, background color, and/or image.


UIContextualAction


func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
return true
}
func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
print("delete")
}
}



This is what it looks like with my current code:What I currently have





Morning and welcome to SO! :) Remember to include some code samples within your question.
– garfbradaz
Jul 1 at 6:21





Thanks! I just added my code above. I know it's not much and I haven't been able to find pretty much anything to help me. I'm just looking for ideas or solutions to ways to achieve a similar result.
– Alex Arovas
Jul 1 at 17:41





stackoverflow.com/questions/1615469/…
– Hunaid Hassan
Jul 1 at 17:53





You are better off creating the entire UI yourself instead of trying to customise the Delete button OS provides
– Hunaid Hassan
Jul 1 at 17:54





Thanks for the link. For the most part a lot of the code is meant for iOS 3-4 and one answer for iOS 7. I'm trying to convert some of their code to swift and make the necessary changes for iOS 11 but I'm still not getting far.
– Alex Arovas
Jul 2 at 6:40




1 Answer
1



Try adding a UIView inside the UITableViewCell, with a red background, and a label inside the UIView with the text of delete. Good Luck!


UITableViewCell


UIView





Thanks for the answer but I'm trying to get the result in the first photo not the second. I also want the clear button to be interactive by sliding over and clearing just like in the iOS Notification Center.
– Alex Arovas
Jul 2 at 6:41






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

How to make file upload 'Required' in Contact Form 7?

Rothschild family

amazon EC2 - How to make wp-config.php to writable?