Chapter 16
Working with Swipe-to-Delete, Context Menu and Action Sheets
Previously, you learned how to present rows of data using a list. In this chapter, we will delve deeper and explore how to enhance user interaction with the list view. Specifically, we will learn how to enable users to:
- Swipe to delete a row
- Tap a row to invoke an action sheet
- Touch and hold a row to bring up a context menu

Previously, you learned about swipe-to-delete and action sheets, as shown in Figure 1. These two user interface elements have been part of iOS for several years. Context menus, on the other hand, were introduced in iOS 13 and resemble the peek and pop functionality of 3D Touch. When a user force-touches a view configured with a context menu, iOS displays a popover menu. As a developer, it's your responsibility to configure the action items that appear in the menu.
While this chapter focuses on interactions within a list, the techniques I'm about to show you can also be applied to other user interface controls, such as buttons.
Preparing the Starter Project
To access the full content and the complete source code, please get your copy at https://www.appcoda.com/swiftui.