I'm trying to customize my searchbar. I need to add two buttons to my searchbar view. I can't to add searchbar to navigationbar, like here Here what i'm trying to do:
CGRect searchFrame = CGRectMake(7, 225, 30, 30);
self.searchButton = [UIButton buttonWithType:UIButtonTypeCustom];
[self.searchButton setBackgroundImage:[UIImage imageNamed:@"magnifier"] forState:UIControlStateNormal];
[self.searchButton setBackgroundColor:[UIColor redColor]];
[self.searchButton setImage:[UIImage imageNamed:@"magnifier"] forState:UIControlStateNormal];
[self.searchButton setFrame:searchFrame];
UITextField *searchField = [self.textSearchBar valueForKey:@"_searchField"];
[searchField setBackgroundColor:[UIColor whiteColor]];
[searchField setLeftView:UITextFieldViewModeNever];
[searchField setBorderStyle:UITextBorderStyleRoundedRect];
searchField.frame = CGRectMake(10, 7, 200, 30);
[self.textSearchBar addSubview:self.searchButton];
[self.textSearchBar reloadInputViews];
But it doesn't work. Can do it? How to add to searchBar subViews?