Swift ListにSectionを追加するサンプル

環境
Swift 5.3

形式
struct ContentView: View {
var body: some View {
List {
Section(header: Text(“xxx"))
ListとSectionを使ってSectionを追加します

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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")
            }
    }
}

 

IT

Posted by arkgame