anonymous No title
No License Swift
2020年06月18日
Copy
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
        })

    }
}
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
        })

    }
}

年末年始は機械学習・深層学習を勉強しませんか?
No one still commented. Please first comment.
年末年始は機械学習・深層学習を勉強しませんか?
広告
未経験から最短でエンジニアへの転職を目指すなら