Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers

up vote 0 down vote accepted
 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

share|improve this answer
    
work fine with search.backgroundImage = [UIColor clearColor]; –  zbMax Jun 18 '13 at 9:50
add comment
/ 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.

share|improve this answer
    
Sorry for the inconvenience, but trying to implement your solution (which unfortunately leads to the problem of this question : stackoverflow.com/questions/3482612/… too), I've been undoing the modification and obtaining the desired result. But thanks for the help. –  zbMax Jun 18 '13 at 7:31
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.