I am trying to accomplish the same look of my UISearchBar with a TextField within it, as in my iOS 6 app. I have tried to code it in several ways and not yet been successful
in iOS 7 to access Text Field you have to reiterate on level more. Change your code like this
for (UIView *subView in self.searchBar.subviews){
for (UIView *ndLeveSubView in subView.subviews){
if ([ndLeveSubView isKindOfClass:[UITextField class]])
{
searchBarTextField = (UITextField *)ndLeveSubView;
break;
}
}
}
But best way to clear backgournd of UISearchBar and setting searchbar icon in text field is:
[searchBar setBackgroundImage:[[UIImage alloc] init] ];//if you want to remove background of uisearchbar
UIImage *image = [UIImage imageNamed: @"search_icon.png"];
[searchBar setImage:image forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal];