I'm trying to change the background color of input field of UISearchBar.It's the rounded view where you input text to search, the default color is white. I would like to change it to gray
I tried:
for (UIView *subView in searchBar.subviews) {
if ([subView isKindOfClass:NSClassFromString(@"UITextField")]) {
UITextField *textField = (UITextField *)subView;
[textField setBackgroundColor:[UIColor grayColor]];
}
But it doesn't work :(
I also tried to insert an image view to TextField but it seems the rounded view is separate from TextField. So, any clues?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…