Chapter 5
Displaying Lists of Items
IN THIS CHAPTER
Displaying collections of items using the List view
Programmatically generating rows in a List view
Adding, deleting, and moving rows
Displaying items in sections
Previewing your user interface in Light and Dark modes
One common task a mobile app developer needs to do is display a list of items. In SwiftUI, the List
view is a container that displays rows of items arranged in a single column.
In this chapter, I show you how to use the List
view to display a list of items. I also explain how to dynamically populate a list, add items to a list, remove items from a list, as well as rearrange the position of items in the list. Finally, I explain how you can preview your user interface (UI) using Apple's new support for Light and Dark modes.
Using the List View to Display Items
In this section, you create a very simple list with a couple of items. In SwiftUI, the List
view presents rows of data displayed in a single column. The following ...
Get SwiftUI For Dummies now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.