我有一个UISearchBar
我已经更改并启用了取消的 bartintcolor。这是作为 UIVew 的子视图添加的。每当使搜索栏可见时,它会在其下方显示一条永不消失的黑线。
我是否缺少有关 UISearchbar 外观或其背景视图的信息。
dummyview=[[UIView alloc]initWithFrame:CGRectMake(10, 30,self.headerView.frame.size.width-20, 30)];
[dummyview setBackgroundColor:[UIColor redColor]];
[dummyview setClipsToBounds:TRUE];
self.searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, dummyview.frame.size.width, dummyview.frame.size.height)];
self.searchBar.delegate = (id)self;
[self.searchBar setPlaceholder:@"Search"];
self.searchBar.showsCancelButton = YES;
_searchBar.barTintColor = [Utilities colorWithHexString:@"3a7ebc"];
[[UIBarButtonItem appearanceWhenContainedIn: [UISearchBar class], nil] setTintColor:[UIColor whiteColor]];
_searchBar.delegate=self;
[dummyview addSubview:_searchBar];
它给了我这样的
如果我将背景更改为原生背景,我会得到替换的内容。
// _searchBar.barTintColor = [Utilities colorWithHexString:@"3a7ebc"];
我只是不想要搜索栏下方的黑线。
更新:使用
_searchBar.searchBarStyle=UISearchBarStyleMinimal;
_searchBar.barStyle=UIBarStyleDefault;
所以最后一切都完成了
_searchBar.searchBarStyle=UISearchBarStyleMinimal;
_searchBar.barStyle=UIBarStyleDefault;
UITextField *searchField=[_searchBar valueForKey:@"_searchField"];
if (searchField) {
[searchField setTextColor:[UIColor whiteColor]];
}