0

I'm looking for having a UiSearchBar with a button at the left. I've been reading this topic, and following the steps described by KennyTM, but I don't manage to have the same result.

Here is what I've got :

enter image description here

As you can see my search bar don't have the same color than my navigation bar.

Does anyone have a solution to this?

Community
  • 1
  • 1
zbMax
  • 2,756
  • 3
  • 21
  • 42

2 Answers2

0
 for( id view in search.subviews) {
        if([view isKindOfClass:[UIImageView class]]) {
            UIImageView *img = (UIImageView *)view;
            img.image = nil;
        }
    }
search.backgroundImage = [UIImage imageNamed:@"searchbar.png"];

search is the object for UISearchbar

Manu
  • 4,730
  • 2
  • 20
  • 45
0
/ button
UIBarButtonItem *settingsButtonItem = // create settings button

// search bar
UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 260, 44)];
UIBarButtonItem *searchBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:searchBar];
[searchBar release];

// toolbar is UIToolbar
[toolbar setItems:[NSArray arrayWithObjects:settingsButtonItem, searchBarButtonItem nil] animated:NO];

Please implement above code may it help lot.

Nimit Parekh
  • 16,776
  • 8
  • 50
  • 72
  • Sorry for the inconvenience, but trying to implement your solution (which unfortunately leads to the problem of this question : http://stackoverflow.com/questions/3482612/adding-button-to-left-of-uisearchbar too), I've been undoing the modification and obtaining the desired result. But thanks for the help. – zbMax Jun 18 '13 at 07:31