0

I created two views that has its transition controlled by a navigation view controller. I have a UIView which contain a UISearchBar. The UIView is then set as the navigation bar's titleView in the first view.

Now, the problem is, whenever I go from the first view to the second view, I can see a light background behind the UISearchBar fading in and out.

I have did a bit of troubleshooting of my own and found that the background belongs to the UISearchBar and not the UIView that contains it. I have also tried many codes to make the UISearchBar background transparent, but none of the codes actually makes it transparent.

enter image description here

Edit: I did a bit more fiddling and found that the colour fading in and out is the colour from the style/tint of the UISearchBar. So if I change the tint to black, it'll darken instead. The only way I see I can fix this is to turn the background of the UISearchBar's alpha to 0, but I can't find any code that can change the alpha of a UISearchBar in a UINavigationBar.

Edit: I really can't find any code to turn the background tint of the UISearchBar to be alpha 0. Does anyone have a workaround or an alternative solution to this?

4

1 に答える 1

1

I realised that the bar is actually the scope bar's background. I'm not sure why it still showed up even though I disabled it. My solution was to set the background image as a transparent image.

[self.searchBar setScopeBarBackgroundImage:[UIImage imageNamed:@"transpixel.png"]];
于 2013-01-14T15:19:59.307 に答える