Working with Swipe-to-Delete, Context Menu and Action Sheets
Previously, you learned how to present rows of data using list. In this chapter, we will dive a little bit deeper and see how to let users interact with the list view including:
- Use swipe to delete a row
- Tap a row to invoke an action sheet
- Touch and hold a row to bring up a context menu
Referring to figure 1, I believe you should be very familiar with swipe-to-delete and action sheet. These two UI elements have been existed in iOS for several years. Context menus are newly introduced in iOS 13, though they look similar to peek and pop of 3D Touch. For any views (e.g. button) implemented with the context menu, iOS will bring up a popover menu whenever a user force touches on the view. For developers, it's your responsibility to configure the action items displayed in the menu.
While this chapter focuses on the interaction of a list, the techniques that I'm going to show you can also be applied to other UI controls such as buttons.
To access the full content and the complete source code, please get your copy at https://www.appcoda.com/swiftui.