Skip to content

Instantly share code, notes, and snippets.

@prafullakumar
Last active September 25, 2021 20:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save prafullakumar/dd1c0ffdf76ba9f10106c7eb521fc0be to your computer and use it in GitHub Desktop.
Save prafullakumar/dd1c0ffdf76ba9f10106c7eb521fc0be to your computer and use it in GitHub Desktop.
import SwiftUI
import UIKit
struct ContentView: View {
var body: some View {
NoSepratorList {
Text("Message 1")
Text("Message 1")
Text("Message 1")
Text("Message 1")
Text("Message 1")
Text("Message 1")
}
}
}
struct NoSepratorList<Content>: View where Content: View {
let content: () -> Content
init(@ViewBuilder content: @escaping () -> Content) {
self.content = content
}
var body: some View {
if #available(iOS 14.0, *) {
ScrollView {
LazyVStack(spacing: 0) {
self.content()
}
}
} else {
List {
self.content()
}
.onAppear {
UITableView.appearance().separatorStyle = .none
}.onDisappear {
UITableView.appearance().separatorStyle = .singleLine
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment