Chapter 2: Going Beyond the Single Component with Lists and Scroll Views
In this chapter, we'll learn how to display lists in SwiftUI. List
views are like UITableViews
in UIKit but are significantly simpler to use. For example, no storyboards or prototype cells are required, and we do not need to remember how many rows or columns we created. Furthermore, SwiftUI's lists are modular so that you can build more significant apps from smaller components.
This chapter will also discuss new and exciting features introduced in WWDC 2021, such as lists with editable text and searchable lists. By the end of this chapter, you will understand how to display lists of static or dynamic items, add or remove items from lists, edit lists, add sections to List
views, and much more.
In this chapter, we'll be covering the following recipes:
- Using scroll views
- Creating a list of static items
- Using custom rows in a list
- Adding rows to a list
- Deleting rows from a list
- Creating an editable List view
- Moving the rows in a List view
- Adding sections to a list
- Creating editable Collections
- Creating Searchable lists