remove lines from list swiftui code example
Example 1: remove divider list swiftui
init() {
UITableView.appearance().separatorColor = .clear
}
var body: some View {
List {
...
}
}
Example 2: swiftui remove list dividers
public struct ListSeparatorStyleNoneModifier: ViewModifier {
public func body(content: Content) -> some View {
content.onAppear {
UITableView.appearance().separatorStyle = .none
}.onDisappear {
UITableView.appearance().separatorStyle = .singleLine
}
}
}
extension View {
public func listSeparatorStyleNone() -> some View {
modifier(ListSeparatorStyleNoneModifier())
}
}
List {
Text("1")
Text("2")
Text("3")
}.listSeparatorStyleNone()