Swift ListにSectionを追加するサンプル
環境
Swift 5.3
形式
struct ContentView: View {
var body: some View {
List {
Section(header: Text(“xxx"))
ListとSectionを使ってSectionを追加します
使用例
import SwiftUI
struct ContentView: View {
var body: some View {
List {
Section(header: Text("Section1")) {
Text("行1")
Text("行2")
Text("行3")
}
Section(header: Text("Section2")) {
Text("行1")
Text("行2")
Text("行3")
}
}
}
import SwiftUI
struct ContentView: View {
var body: some View {
List {
Section(header: Text("Section1")) {
Text("行1")
Text("行2")
Text("行3")
}
Section(header: Text("Section2")) {
Text("行1")
Text("行2")
Text("行3")
}
}
}
import SwiftUI struct ContentView: View { var body: some View { List { Section(header: Text("Section1")) { Text("行1") Text("行2") Text("行3") } Section(header: Text("Section2")) { Text("行1") Text("行2") Text("行3") } } }