How to resize UISearchBar height in iOS?

I created a UISearchBar with 100 as height, but it does not take size and has a default size of 44. Is there any UISearchBar height size?

+4
source share
3 answers

You can set your own image for the search field, and this will allow you to create a control of various sizes.

[searchBar setSearchFieldBackgroundImage:[UIImage imageNamed:@"SearchTextbox"] forState:UIControlStateNormal]; 

You can manually override the height of the search string inside layoutSubViews as follows

 - (void)layoutSubviews { frame = self.frame; if (frame.size.height != 100) { frame.size.height = 100; self.frame = frame; } } 
+2
source

If I understand your question correctly, you are trying to resize the UISearchBar, right? Have you tried to adjust the size of its frame?

 NSLog(@"Adding UISearchBar to myView."); UISearchBar *searchBar = [[UISearchBar alloc] init]; [myView addSubview:searchBar]; // Make the search bar will take up the entire window. searchBar.frame = [[UIApplication sharedApplication] keyWindow].frame; // Release the searchBar (it is being retained by myView) [searchBar release]; 

If you are trying to resize the UITextField subtitle in a UISearchBar, I'm afraid you are out of luck, as described in detail in this post on SO ., The UITextField inside the UISearchBar is part of a private API, an instance of UISearchBarTextField, and you cannot resize it (by any Apple will approve it). However, the UISearchBar offers ways to change the text offset in the UISearchBar. See the documentation for the UISearchBar class.

0
source

Just go to the height of the restrictions and set their height. Bingo:)

-1
source

All Articles