I'm trying to color this UISearchBar so that it looks seamless with the background (like in the second image). Is it possible to do this? I've tried setting in IB and programmatically but no luck.
thanks for any help
Here's the desired look:
UITextField *searchField = [self.searchBar valueForKey:@"_searchField"];
[searchField setBackground:[UIImage imageNamed:@"searchfield_bg"]];
[self.searchBar setTintColor:[UIColor blackColor]];
UIImage *searchimg = [UIImage imageNamed:@"search_panel.png"];
for (UIView *subview in self.searchBar.subviews) {
if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
UIView *bg = [[UIView alloc] initWithFrame:subview.frame];
bg.backgroundColor = [UIColor colorWithPatternImage:searchimg];
[self.searchBar insertSubview:bg aboveSubview:subview];
[subview removeFromSuperview];
[bg release];
break;
}
}
Im using these images, you can use your and change the color too, my requirements were to make a black searchbar so im using black color
and it will look like: