In iOS 7, the properties backgroundImage
and scopeBarBackgroundImage
no longer work as expected and become translucent.
The following method has been introduced in iOS 7 which addresses this problem. (Docs here)
setBackgroundImage:forBarPosition:barMetrics:
Here's what you should do :
[self.searchDisplayController.searchBar setBackgroundImage:[self imageWithColor:[UIColor yourColor]]
forBarPosition:0
barMetrics:UIBarMetricsDefault];
Here, barPosition : 0
is UIBarPositionAny
.
Edit:
Swift code:
self.searchDisplayController.searchBar.setBackgroundImage(self.image(color: UIColor.yourColor), for: UIBarPosition(rawValue: 0)!, barMetrics:.default)