【发布时间】:2013-12-19 20:49:29
【问题描述】:
我正在尝试更改搜索栏的背景颜色。我希望这个顶视图是一种纯色。这是我正在使用的代码:
[titleBarView setBackgroundColor:[ColorUtil colorWithHexString:@"1ABC9C"]];
searchBar.barTintColor=[ColorUtil colorWithHexString:@"1ABC9C"];
searchBar.backgroundColor=[ColorUtil colorWithHexString:@"1ABC9C"];
下面是我得到的结果。请注意,搜索栏的顶部和底部边缘有一些灰色。我该如何摆脱它?
编辑:添加后
searchBar.searchBarStyle=UISearchBarStyleMinimal;
我现在明白了:
所以我原来的问题解决了,但是现在 searchBar 的内部颜色是错误的。什么属性支配它?
【问题讨论】:
-
您的视图层次结构如何?你试过
[searchBar setBarTintColor:[UIColor clearColor]]; -
这对我有用。请创建一个答案,以便我接受。
标签: ios iphone background uisearchbar