I want to customize the search bar, I mean the white box. Can I do it? Is there some documentation about that? Is there a way to hide the white box, but not the letters. Can I at least make the box smaller? I mean less height
Change Search Bar Default Image Color The left hand default search image in UISearchBar represents the left view of the UITextField. The Image is rendered to change it to the desired colour. @IBOutlet weak var searchBar: UISearchBar! Hope it will help you in customising the UISearchBar in your app.
By IOS 5.0 you have the chance to use
[[UISearchBar appearance] setSearchFieldBackgroundImage:[UIImage imageNamed:@"searchbar.png"]forState:UIControlStateNormal];
Here is the solution I was looking for: Subclassing a UISearchBar, & overwriting the method layoutSubviews
- (void)layoutSubviews { UITextField *searchField; NSUInteger numViews = [self.subviews count]; for(int i = 0; i < numViews; i++) { if([[self.subviews objectAtIndex:i] isKindOfClass:[UITextField class]]) { //conform? searchField = [self.subviews objectAtIndex:i]; } } if(!(searchField == nil)) { searchField.textColor = [UIColor whiteColor]; [searchField setBackground: [UIImage imageNamed:@"buscador.png"] ]; [searchField setBorderStyle:UITextBorderStyleNone]; } [super layoutSubviews]; }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With