My goal is to prevent the cancel button from appearing in a search bar in a UISearchController. I started with Apple\'s Table Search with UISearchController sample code and
The following github project subclasses UISearchBar which is presented as solution 2:
https://github.com/mechaman/CustomSearchControllerSwift
On top of it, it also subclasses UISearchController to enable one to put the search bar in places other than the tableView header!
Hope this helps.