ios 修改搜索框里文本框的背景

//搜索框
_searchBar = [[UISearchBar alloc] init];
[_searchBar setPlaceholder:@"寻找餐厅美食"];

for (UIView *obj in [_searchBar subviews]) {
    for (UIView *objs in [obj subviews]) {
        if ([objs isKindOfClass:NSClassFromString(@"UITextField")]){
            [objs setBackgroundColor:[UIColor colorWithHexString:@"#EDEDED"]];
        }
    }
    
    if ([obj isKindOfClass:NSClassFromString(@"UITextField")]){
        [obj setBackgroundColor:[UIColor colorWithHexString:@"#EDEDED"]];
    }
}

你可能感兴趣的:(ios 修改搜索框里文本框的背景)