So the question is pretty simple and it's in the title. I want to remove the line separator in SwiftUI iOS 14. Previously, I was using UITableView().appearance().separatorStyle = .none
and that used to do the job in iOS 13. Now however, it doesn't work. Any update or idea on how to make it work. Thanks:)
Unfortunately, there is no official way to remove line separators in SwiftUI. That said, we can make use of the UIKit API to tweak the line separator of the List view in SwiftUI.
Changing SwiftUI Divider Colors You can change its color by overlay it with the color you want using . overlay() modifier. Text("A visual element that can be used to separate other content.") Use overlay modifier to change the color of a divider.
Probably the simplest way to build a list is to create a new SwiftUI view and wrap the Hello World text in a List: struct StaticListView: View { var body: some View { List { Text("Hello, world!") } } } To add more items to the list, we can just add another line: List { Text("Hello, world!") Text("Hello, SwiftUI!") }
Here is a demo of possible solution. Tested with Xcode 12b.
List { ForEach(0..<3) { _ in VStack { Text("Hello, World!").padding(.leading) } .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading) .listRowInsets(EdgeInsets()) .background(Color.white) } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With