I'm trying to figure out how to add a searchbar and a scope as a header to my UIViewController programmatically I want it to be at the top of the safe area. The issue is I don't know the code to add it at the top of the safe area below the title of the UIViewController and bar button item.
func customizeSearch() {
let searchBar = UISearchBar(frame: CGRect(x:0, y:0, width: (UIScreen.main.bounds.width), height: 70))
searchBar.backgroundColor = UIColor.black
searchBar.delegate = self
searchBar.scopeButtonTitles = ["All", "Forwards", "Defensemen", "Goalies"]
/*self.tableView.tableHeaderView = searchBar if I had a tableview, I have a vc instead.*/
}