Answers for "swiftui list separator"

2

remove divider list swiftui

init() {
	UITableView.appearance().separatorColor = .clear
}

var body: some View {
   List {
      ...
   }
}
Posted by: Guest on March-16-2020
1

swiftui remove list dividers

// while this solution works correctly let's clean up the work using ViewModifier

public struct ListSeparatorStyleNoneModifier: ViewModifier {
    public func body(content: Content) -> some View {
        content.onAppear {
            UITableView.appearance().separatorStyle = .none
        }.onDisappear {
            UITableView.appearance().separatorStyle = .singleLine
        }
    }
}

// now let's make a small extension that would help to hide the details
 
extension View {
    public func listSeparatorStyleNone() -> some View {
        modifier(ListSeparatorStyleNoneModifier())
    }
}

// As you can see, we’ve wrapped our appearance setting code into a neat little view modifier. you can declare it directly now

List {
    Text("1")
    Text("2")
    Text("3")
}.listSeparatorStyleNone()
Posted by: Guest on March-16-2020

Code answers related to "Swift"

Browse Popular Code Answers by Language