Swift リストの要素ごとのに表示する区切り線の色を設定するサンプル

環境
Swift version 5.2.3 (swift-5.2.3-RELEASE)

構文
ItemView()
.listRowSeparatorTint(/*区切り線の色*/)
Listの区切り線の色を設定するには、listRowSeparatorTint修飾子を使います。
listRowSeparatorTint(/*区切り線の色*/)で指定した色は、付与した要素の周りの区切り線の色を変えます。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
struct ContentView: View {
var body: some View {
List {
ForEach (0..<5, id: \.self) { index in
Text("Text\(index + 1)")
.listRowSeparatorTint(Color.yellow)
}
Text("saat66")
.listRowSeparatorTint(Color.blue)
Text("tuu77s")
}
}
}
struct ContentView: View { var body: some View { List { ForEach (0..<5, id: \.self) { index in Text("Text\(index + 1)") .listRowSeparatorTint(Color.yellow) } Text("saat66") .listRowSeparatorTint(Color.blue) Text("tuu77s") } } }
struct ContentView: View {
    
    var body: some View {
        List {
            
            ForEach (0..<5, id: \.self) { index in
                Text("Text\(index + 1)")
                    .listRowSeparatorTint(Color.yellow)
            }
            Text("saat66")
                .listRowSeparatorTint(Color.blue)
            Text("tuu77s")
        }

    }
    
}

 

IT

Posted by arkgame