Can’t seem to figure this thing. In my list, I have these white (black in dark mode) lines before the text, which I fail to get rid of. Somebody told me that this means that I coded something wrong. But what is it? Here’s my code:
import SwiftUI
struct ContentView: View {
init(){
UITableView.appearance().backgroundColor = .clear
}
var body: some View {
List {
Text("List Item 1").listRowBackground(Color("customColor"))
Text("List Item 2").listRowBackground(Color("customColor"))
Text("List Item 3").listRowBackground(Color("customColor"))
Text("List Item 4").listRowBackground(Color("customColor"))
Text("List Item 5").listRowBackground(Color("customColor"))
}.background(Color("customColor"))
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
And then in the appDelegates (didFinishLaunchingWithOptions) I put in this:
UITableView.appearance().separatorColor = .darkGray.
Found several topics about list background colors but in those nobody seems to care about these annoying lines. What do I do to get rid of them?
SwiftUI 2.0
No changes needed - works as-is
SwiftUI 1.0+
Here is a fix (tested with Xcode 11.4 / iOS 13.4)
UITableViewCell.appearance().backgroundColor = .clear // << add this one !!
UITableView.appearance().backgroundColor = .clear