gpt4 book ai didi

ios - UIsearchbar 在它下面显示一条永远不会消失的线

转载 作者:行者123 更新时间:2023-11-28 06:51:15 25 4
gpt4 key购买 nike

我有一个 UISearchBar,我已经更改了它的 bartintcolor 并启用了取消。这是作为 UIVew 的 subview 添加的。每当使搜索栏可见时,它都会在其下方显示一条永远不会消失的黑线。

我是否缺少有关 UISearchbar 外观或其背景 View 的信息。

    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];

它给我这样的感觉

Black line color just below

如果我将背景更改为原生背景,我会得到置换的内容。//_searchBar.barTintColor = [Utilities colorWithHexString:@"3a7ebc"];

enter image description here

我只是不想要搜索栏下方的黑线。

更新:使用_searchBar.searchBarStyle=UISearchBarStyleMinimal;
_searchBar.barStyle=UIBarStyleDefault;

结果 enter image description here

所以终于一切都完成了

_searchBar.searchBarStyle=UISearchBarStyleMinimal;
_searchBar.barStyle=UIBarStyleDefault;
UITextField *searchField=[_searchBar valueForKey:@"_searchField"];
如果(搜索字段){
[searchField setTextColor:[UIColor whiteColor]];
}

最佳答案

将我的代码放在 viewdidload 或 viewwillappear 方法中。

searchbar.barTintColor=[UIColor samebgcolor];
searchbar.layer.borderWidth = 1;
searchbar.layer.borderColor = [[UIColor samebgcolor] CGColor];

我也会考虑,“我希望这对你有帮助”,因为这是最强的,并且希望这件事肯定会有所帮助。

如果您喜欢我的回答,请采纳并点赞

关于ios - UIsearchbar 在它下面显示一条永远不会消失的线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33755210/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com