我正在将UI从iOS 6过渡到iOS 7。
我们有一个与UISearchDisplayController相关的UISearchBar,我已经将navigationBar和searchBar的backgroundImage设置为使用颜色动态创建的1x1图像。
self.searchDisplayController.searchBar.translucent = NO;
self.searchDisplayController.searchBar.barTintColor = [UIColor clearColor];
self.searchDisplayController.searchBar.tintColor = [UIColor myTintColor];
self.searchDisplayController.searchBar.backgroundImage = [self imageWithColor:[UIColor myBGColor]];
self.searchDisplayController.searchBar.scopeBarBackgroundImage = [self imageWithColor:[UIColor myBGColor]];
在iOS6上,一切都按预期工作。
在iOS7上,当选择searchBar时,scopeBar会显示出良好的背景图片(使用searchBar.scopeBarBackgroundImage设置),但是searchBar会变成半透明灰色。当我点击“取消”时,searchBar的背景图像会恢复。
/////////////////////////////////////////////////////////////////////////////////////////////////////
修改后的问题
/////////////////////////////////////////////////////////////////////////////////////////////////////
实际上,我在这里和那里使用了barTintColor和其他选项,但它们不起作用。下面是将barTintColor设置为相同颜色的结果。但是顶部有一个白色层。