我有一個UISearchBar
其bartintcolor我已經改變,並取消啓用。這是作爲UIVew的子視圖添加的。每當使搜索欄可見時,它會在其下方顯示一條永不消失的黑線。UIsearchbar在它下面顯示一條永遠不會去的線
我是否錯過了關於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]]; }
你試過[這](http://stackoverflow.com/questions/6868214/remove-the-1px-border-under-uisearchbar) –
我想我試過這些。讓我再嘗試一次。 –
更改搜索欄樣式最小屬性。 –