Reputation: 149
I have a navigationbar in navigationbarcontroller which is connected to my table view.
Now for a nice design I have the search bar in the navigation controller, and then above the navigation controller, I'd like to have a button on each side.
But I have a problem. An image of the problem is below as well as the code. I'd like to move the search bar below the side buttons and not beside them.
let searchbar = UISearchBar()
searchbar.showsCancelButton = false
searchbar.placeholder = "Search any Product"
searchbar.delegate = self
self.navigationItem.titleView = searchbar
Upvotes: 0
Views: 827
Reputation: 2469
You could put the searchbar in the headerview of the tableview. This way you also have easy ways of hiding the searchbar.
Below is the link for a small tutorial which shows how to do it, ofc you can customize the color and stuff but this is the basic setup.
https://www.ioscreator.com/tutorials/add-search-table-view-tutorial-ios8-swift
Upvotes: 1