LoginSignup
2
2

【SwiftUI】Listの灰色の部分の色を変更する

Posted at

はじめに

リストの灰色部分の色を変更したいことがあったのでやり方を記録しておきます。

灰色の部分ってどこ?

リストのセル以外の部分です。
Simulator Screenshot - iPhone 14 - 2023-05-28 at 22.07.24.png

実装

今回は灰色の部分を緑にしてみます。

import SwiftUI

struct ContentView: View {
    var body: some View {
        List {
            ForEach(0..<10) { index in
                Text("セル\(index)")
            }
        }
        .listStyle(.insetGrouped)
+       .scrollContentBackground(.hidden)
+       .background(Color.green)
    }
}

simulator_screenshot_041DD2B7-B3C5-41B8-8DEC-CEDD9202A30C.png

おわり

いい感じに緑になりましたねー

2
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
2