我正在iOS 6和iOS 7之间进行UI转换.
我们有一个与UISearchDisplayController相关的UISearchBar,我已经将navigationBar的backgroundImage和searchBar设置为用颜色动态创建的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]];
Run Code Online (Sandbox Code Playgroud)
在iOS6上,一切都按预期工作.在iOS7上,当选择了searchBar时,scopeBar会出现好的backgroundImage(使用searchBar.scopeBarBackgroundImage设置),但searchBar是一种半透明的灰色.当我按下取消时,searchBar backgroundImage又回来了.

////////////////////////////////////////////////// ////////////////////////////////////////////////// /
编辑问题
////////////////////////////////////////////////// ////////////////////////////////////////////////// /
实际上,我确实在这里和那里使用了barTintColor和其他选项,但它不起作用.这是barTintColor设置为相同颜色的结果.但是顶部有这个白色层
