4

I am trying to changing the black area of a section inside of a form using SwiftUI.

Since Swift 2.0 in iOS 14, a form shows these with a of padding, but using background and foreground for the colors, does not change the part I need to change.

Is there a modifier that changes the black part (in dark mode) to any other colour?

So far I have:

Form {
    Section(header: Text("User Details")) {
        Text("Name:").background(Color.red)
        Text("Email:").foregroundColor(Color.red)
    }
}

enter image description here

jwknz
  • 6,598
  • 16
  • 72
  • 115

1 Answers1

10

try this:

Form {
    Section(header: Text("User Details")) {
         Text("Name:").background(Color.red)
         Text("Email:").foregroundColor(Color.red)
    }.listRowBackground(Color.green)
}
  • 1
    If you want to make it .clear SwiftUI will ignore you and place a dark default view as normal unless you set the following appearance proxy on view appearance: `.onAppear { UITableViewCell.appearance().backgroundColor = UIColor.clear }` – M3nd3z Jan 26 '21 at 16:44
  • This one is really an unexpected and weird behaviour that bugged me for a while. Thanks! @M3nd3z – Okhan Okbay Jul 27 '22 at 09:57