使UISearchBar背景清晰 [英] Make UISearchBar background clear

查看:84
本文介绍了使UISearchBar背景清晰的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法清除搜索栏我试图通过设置其背景颜色来清楚地表达它,并且我还在搜索栏下放置了一个图像

I am not able to clear search bar I have tried to make it clear by setting its background color clear and I have also placed one image under searchbar

我有也明确了搜索栏的背景

I have also made clear background of searchbar

 for (UIView *subview in self.searchBarHome.subviews) {
      if ([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) {
         [subview removeFromSuperview];//please help me to make clear background of uisearchbar
        break; 
    }
}
[self.searchBarHome setBackgroundColor:[UIColor clearColor]];


推荐答案

对于iOS7 +,您需要做的就是:

For iOS7+, all you need to do is:

[self.searchBarHome setBackgroundColor:[UIColor clearColor]];
[self.searchBarHome setBarTintColor:[UIColor clearColor]]; //this is what you want

注意:这将是不能用于iOS6

NOTE: This will not work for iOS6

对于iOS6 +,即使在iOS7中,以下内容也会处理:

For iOS6+, the following will take care of it even in iOS7:

[self.searchBarHome setBackgroundColor:[UIColor clearColor]];
[self.searchBarHome setBackgroundImage:[UIImage new]];
[self.searchBarHome setTranslucent:YES];

这篇关于使UISearchBar背景清晰的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆