どうも、ちょげ(@chogetarou)です。
リストの要素ごとのに表示する区切り線の色を設定する方法を紹介します。
方法

Listの区切り線の色を設定するには、listRowSeparatorTint修飾子を使います。
まず、Listの要素にlistRowSeparatorTint修飾子を付与します。
そして、listRowSeparatorTint修飾子の引数に区切り線の色を指定します。
List {
ItemView()
.listRowSeparatorTint(/*区切り線の色*/)
・・・
}
listRowSeparatorTint(/*区切り線の色*/)で指定した色は、付与した要素の周りの区切り線の色を変えます。
使用例
以下は、使用例です。

struct ContentView: View {
var body: some View {
List {
ForEach (0..<5, id: \.self) { index in
Text("Text\(index + 1)")
.listRowSeparatorTint(Color.blue)
}
Text("Text6")
.listRowSeparatorTint(Color.red)
Text("Text7")
}
}
}
コメント