// searchBar
背景颜色
searchBar.barTintColor = [UIColor colorWithRed:1 green:1 blue:1 alpha:1];
// 设置searchBar中textField的图标和背景颜色
UIView *searchBarSubview = [searchBar.subviews objectAtIndex:0];
for (UIView *subview in searchBarSubview.subviews) {
for (UIView *subview in searchBarSubview.subviews) {
if ([subview isKindOfClass:[UITextFieldclass]])
{
UITextField *searchField = (UITextField *)subview;
[searchField setBackgroundColor:[UIColor colorWithRed:1 green:1 blue:1 alpha:1]];
searchField.leftView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"search-icon"]];
[searchField setBackgroundColor:[UIColor colorWithRed:1 green:1 blue:1 alpha:1]];
searchField.leftView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"search-icon"]];
break;
}
}
}