I’m creating an app that needs three separate search boxes. I want them to look like the standard search bar and look like one element (ie. if I stack three search bars, they have a separator between each and gradient, which makes them look like separate elements).
My question is, should I go with this and use something like this to remove the background layer, or should I use 3 text fields in a view, styled with background images etc. to look like search boxes?
Thanks.
Use three normal UISearchBars stacked and put a UIImageView with the background you want behind them.
Then, in the code of your controller, in your viewDidLoad method, do this for each search bar:
This works fine on iOS 4 and earlier and I think it’s fine on iOS5 a well, but it is a little unsafe if Apple ever change the internals of UISearchBar, so for future proofing purposes, you may actually want to do this instead:
Then just add a single-pixel transparent.png to your project to use as the search bar background on iOS5 (it will tile/stretch to fill the bar).