9
votes

I have a collection view that I would like to be searchable. On top of this, if a user types in something that isn't in the collection view, I would like it to go ahead and search the database for it.

Currently I'm using a SearchController and am trying to heavily customize the UISearchBar that comes with a SearchController to look like this:

enter image description here

I've gotten it to look like this so far:

enter image description here

Some of the problems I'm currently running into with the UISearchBar are:

  1. Having the text initially appear on the left side before the user clicks on the search field
  2. Positioning the text in the search field to be a little lower
  3. Making the image that I replace the default search icon with not expand to the initial search icon's height (that's why it looks blurry)

Would it make more sense for me to just use a UITextField instead of a SearchController or is there a way I can replace the UISearchBar that comes with the SearchController with a UITextField?

1
Thomas, is this something you have had answered or figured out on your own. I have the same question but don't have any prior experience with UISearchBar, UISearchController, etc.Drew Burnett
I just answered my question @AndrewBurnettThomas

1 Answers

9
votes

I ended up getting this to look exactly what I needed it to look like by using a UITextField, and making it work like a searchDisplayController by overriding the textFieldDidBeginEditing and textFieldDidChange methods