SwiftUI Docs
老年人备忘录Fast, readable references
组件Components

ListList

高效渲染滚动列表,适合设置页、导航列表和数据集合展示。Efficient scrolling lists for settings, navigation, and data collections.

中级Intermediate5 分钟5 min
更新于Updated Apr 22, 2026

列表结构List Structure

List 内部通常搭配 ForEach 和 Section 来组织多组数据。List is commonly combined with ForEach and Section to organize grouped data.

分组列表Grouped List
swift
1List {
2 Section("Favorites") {
3 ForEach(items) { item in
4 Text(item.title)
5 }
6 }
7}
8.listStyle(.insetGrouped)
Favorites
item.title
item.title
item.title
性能建议Performance Tip

大型数据集合优先保证元素标识稳定,避免在 ForEach 中使用会频繁变化的 id。For large data sets, keep element identity stable and avoid frequently changing ids in ForEach.