I want to make a simple app that has a table with a bar (~50px high) at the top of the view. The bar will include a search button. When pressing the search button I would like to swap out the view in the bar with a search bar. I can’t think of the best way to do this.
I have several options here. I could do it programmatically or make custom .xib files of each view and have them swapped out. With the custom .xib files, I don’t know how to pass the functionality to the main ViewController.
I figure there is something out there somewhere regarding this in bits and pieces. I wanted to get some opinions on what the best way to do this is.
I achieved this functionality in this way:
In your code:
Set the UISearchBar’s frame to equal the toolbar’s frame.
[self.searchBar setFrame:self.toolBar.frame];Create a “Search” button in the toolbar which will set searchBar’s isHidden = NO and toolBar’s isHidden = YES.
This will have no animations. Just a complete replace.
To have it animate, use something like: