自定义UISearchBar:试图摆脱搜索栏下方的1px黑线 [英] Customize UISearchBar: Trying to get rid of the 1px black line underneath the search bar

查看:118
本文介绍了自定义UISearchBar:试图摆脱搜索栏下方的1px黑线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题已在标题中指明:我想摆脱 UISearchBar 底部绘制的黑线。有什么想法?

My question is already specified in the title: I would like to get rid of the black line drawn on the bottom of the UISearchBar. Any ideas?

这是我的意思的图像:

更新

我认为该行是 UITableView tableHeaderView 。我仍然不知道如何删除它。

I think that the line is part of the UITableView's tableHeaderView. I still don't know how to remove it.

推荐答案

我通过添加子视图修复此问题 searchBar 的视图堆栈如下:

I fixed this by adding a subview to the searchBar's view stack like so:

CGRect rect = self.searchBar.frame;
UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0, rect.size.height-2,rect.size.width, 2)];
lineView.backgroundColor = [UIColor whiteColor];
[self.searchBar addSubview:lineView];

此处, self.searchBar UISearchBar 我的控制器类的指针。

Here, self.searchBar is an UISearchBar pointer of my controller class.

这篇关于自定义UISearchBar:试图摆脱搜索栏下方的1px黑线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆