UISearchBar和UISearchDisplayController背景颜色

时间:2015-04-23 09:22:06

标签: ios uisearchbar uisearchdisplaycontroller uisearchcontroller

我已在导航栏中添加UISearchBar,当用户点按某个按钮时,该UISearchDisplayController可见。另外,我已经以编程方式链接了UISearchDisplayController。搜索栏的背景颜色是透明的。

我的问题是,当黑色的半透明叠加层被点击并且UISearchDisplayController变为非活动状态时,我会看到一个非常难看的搜索栏动画:它会延伸到完整尺寸(不再显示取消按钮) )并应用某种灰色背景。

当用户点按取消按钮以使#include <jni.h> //This code is not defined: #ifdef WORD #include "Word.h" #endif //...rest of code 变为无效时,一切都很好。

有没有人能解决我的问题?

感谢。

2 个答案:

答案 0 :(得分:0)

您可以制作自定义背景图片:

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

searchBarBackground

searchBarBackground

setSearchFieldBackgroundImage - 透明图像 setSearchFieldBackgroundImage

答案 1 :(得分:0)

因为我使用的是 UIViewController + MMDrawerController.h ,所以设置 UISearchDisplayController 的正确方法是:

[[UISearchDisplayController alloc] initWithSearchBar:search
                                  contentsController:self.mm_drawerController.centerViewController];
相关问题