
Swift
struct TableViewConfigurator: UIViewControllerRepresentable {
var configure: (UITableView) -> Void = { _ in }
func makeUIViewController(context: UIViewControllerRepresentableContext<TableViewConfigurator>) -> UIViewController {
UIViewController()
}
func updateUIViewController(_ uiViewController: UIViewController, context: UIViewControllerRepresentableContext<TableViewConfigurator>) {
DispatchQueue.main.async {
let tableViews = ViewRetriever.retrieve(parentView: uiViewController.navigationController?.topViewController?.view, inspection: { $0 as? UITableView})
for tableView in tableViews {
self.configure(tableView)
}
}
}
}
struct ContentView: View {
var body: some View {
List {
.
.
.
}
.background(TableViewConfigurator {
$0.backgroundColor = .clear
$0.separatorStyle = .none
})
}
}