search bar change image inside of search bar (white by default)
UITextField *searchField;
NSUInteger numViews = [searchBar_.subviews count];
for(int i = 0; i < numViews; i++)
{
if([[searchBar_.subviews objectAtIndex:i] isKindOfClass:[UITextField class]])
{ //conform?
searchField = [searchBar_.subviews objectAtIndex:i];
}
}
if(!(searchField == nil)) {
searchField.textColor = [UIColor whiteColor];
[searchField setBackground: [UIImage imageNamed:@"submit-button@2x.png"]];//just add here gray image which you display in quetion
[searchField setBorderStyle:UITextBorderStyleNone];
}
change search icon in search bar…
- (void)setSearchIconToFavicon
{
// Really a UISearchBarTextField, but the header is private.
UITextField *searchField = nil;
for (UIView *subview in searchBar_.subviews) {
if ([subview isKindOfClass:[UITextField class]]) {
searchField = (UITextField *)subview;
break;
}
}
if (searchField) {
UIImage *image = [UIImage imageNamed: @"icon.png"];
UIImageView *iView = [[UIImageView alloc] initWithImage:image];
searchField.leftView = iView;
}
}
No comments:
Post a Comment