0

I have been searching around everywhere and there does not seem to be a solution to change the UISearchBar height in Swift. How would you change it. I don't want to do a lot of setup because I already have customized the searchBars color and font, but how would you change the height?

  • Is the search bar defined in code or in a storyboard/xib? – dudeman Jul 27 '15 at 16:55
  • http://stackoverflow.com/questions/30858969/can-the-height-of-the-uisearchbar-textfield-be-modified – Adrian Jul 27 '15 at 16:59
  • 1
    I suggest implementing your own search bar. Having a custom search bar can really be tricky to make it look like as you want (not to say impossible). To do that you will have to use the textField delegate functions shouldChangeCharactersInRange, and textFielddidChange using a control event : self.mSearchTextField.addTarget(self, action: "textFieldDidChange:", forControlEvents: UIControlEvents.EditingChanged) – Swift Rabbit Jul 27 '15 at 17:03

2 Answers2

0

Select your SearchBar in storyboard and go to "Identity inspector" and copy the ID.Now open the Main.storyboard in "Source code editor" and find your id and alter the required height.

You will get the SearchBar id ,see the photo

you will get this screen in editor and the height

Krunal
  • 77,632
  • 48
  • 245
  • 261
Narendra Sharma
  • 549
  • 4
  • 15
0

Add height constraint to your search bar in storyboard view.

This snapshot make it easy to understand.

enter image description here

Krunal
  • 77,632
  • 48
  • 245
  • 261