可以通过protocol ListStyle 修改List样式
//
// ListStyle.swift
// List
//
// Created by lsr on 2021/9/22.
//
import SwiftUI
struct ListStyle: View {
@State var dataItems = dataSourceWithClass;
var body: some View {
List{
ForEach(dataItems) { region in
Section(header: Text(region.studentClass.name)) {
ForEach(region.students) { item in
ListRow(item: item)
}
}
}
}.listStyle(InsetGroupedListStyle()).navigationTitle("人员管理")
}
}
struct ListStyle_Previews: PreviewProvider {
static var previews: some View {
ListStyle()
}
}
效果如下
InsetGroupedListStyle
DefaultListStyle
GroupedListStyle
InsetListStyle
PlainListStyle
SidebarListStyle