Add SearchBar and Scope Programmatically

I'm trying to figure out how to add a searchbar and a scope as a header to my UIViewController. The issue is I don't know the code to add it as a header.

   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.
  }
Answered by ZoneX in 670505022
I was able to do it.
Accepted Answer
I was able to do it.
Add SearchBar and Scope Programmatically
 
 
Q