iOS:UISearchBar背景问题

时间:2013-12-03 17:00:20

标签: ios iphone background uisearchbar

我正在尝试更改搜索栏的背景颜色。我希望这个顶视图是一种纯色。这是我正在使用的代码:

 [titleBarView setBackgroundColor:[ColorUtil colorWithHexString:@"1ABC9C"]];
searchBar.barTintColor=[ColorUtil colorWithHexString:@"1ABC9C"];
searchBar.backgroundColor=[ColorUtil colorWithHexString:@"1ABC9C"];

以下是我得到的结果。请注意,搜索栏的顶部和底部边缘有一些灰色。我怎么摆脱这个?

enter image description here

编辑:添加

 searchBar.searchBarStyle=UISearchBarStyleMinimal;

我现在知道了:

enter image description here

所以我的原始问题已经解决,但现在searchBar的内部是错误的颜色。什么财产管辖那个?

2 个答案:

答案 0 :(得分:1)

您的视图层次结构如何?你试过[searchBar setBarTintColor:[UIColor clearColor]];

吗?

答案 1 :(得分:0)

尝试:
searchBar.searchBarStyle = UISearchBarStyleMinimal;

参考:https://developer.apple.com/library/ios/documentation/UIKit/Reference/UISearchBar_Class/Reference.html