Last active
September 25, 2021 20:21
-
-
Save prafullakumar/dd1c0ffdf76ba9f10106c7eb521fc0be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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