I am using UISearchController to present a search bar inside the header view of a tableview:
... self.searchController.hidesNavigationBarDuringPresentation =
its very simple just do clipsToBounds = true of header view of table view in witch search bar is added.
countryTableView.tableHeaderView?.clipsToBounds = true