I am trying to have a banner as the header view where the SwiftUI Color blue stretches the full width and takes about 200 points as height. I am just getting an empty view.
func makeUIView(context: Context) -> UITableView {
let tableView = UITableView()
tableView.delegate = context.coordinator
tableView.dataSource = context.coordinator
tableView.register(UITableViewCell.self, forCellReuseIdentifier: "cell")
let vc = UIHostingController(rootView: Color.blue.frame(height: 200))
let headerView = UIViewType(frame: CGRect(x: 0, y: 0, width: tableView.frame.width, height: 200))
headerView.addSubview(vc.view)
headerView.translatesAutoresizingMaskIntoConstraints = false
tableView.addSubview(headerView)
NSLayoutConstraint.activate([
headerView.widthAnchor.constraint(equalTo: tableView.widthAnchor),
headerView.topAnchor.constraint(equalTo: tableView.topAnchor),
headerView.heightAnchor.constraint(equalToConstant: 200)
])
tableView.tableHeaderView = headerView
return tableView
}