0

I've added a UISearchBar into the navigation bar which it's visible when the user taps a certain button. Also, I've linked programmatically a UISearchDisplayController. The background color for the search bar is transparent.

My problem is that when the black semi-transparent overlay it's tapped and the UISearchDisplayController becomes inactive, I see a very ugly search bar animation: it stretches to full size (not showing cancel button anymore) and applying some kind o grey background.

When the user taps the cancel button in order to UISearchDisplayController become inactive everything it's fine.

Does anyone have a solution for my problem?

Thanks.

blancos
  • 1,576
  • 2
  • 16
  • 38
dorin
  • 873
  • 2
  • 15
  • 34

2 Answers2

0

You can make custom background images:

[searchBar setBackgroundImage:[UIImage imageNamed:@"searchBarBackground"]];
[searchBar setScopeBarBackgroundImage:[UIImage imageNamed:@"searchBarBackground"]];
[searchBar setSearchFieldBackgroundImage:[UIImage imageNamed:@"searchFieldBackgroundImage"] forState:UIControlStateNormal];

searchBarBackground

searchBarBackground

setSearchFieldBackgroundImage - transparent image setSearchFieldBackgroundImage

OMGHaveFun
  • 838
  • 1
  • 10
  • 16
0

Because I was using UIViewController+MMDrawerController.h the correct way of setting UISearchDisplayController was:

[[UISearchDisplayController alloc] initWithSearchBar:search
                                  contentsController:self.mm_drawerController.centerViewController];
dorin
  • 873
  • 2
  • 15
  • 34