所以我现在的处境有点复杂,
问题:,只有在导航栏下,才有一条超薄的蓝线穿过我的自定义UITableViewSectionHeader ,而我不知道从哪里来:
我有:
[

我的理论:
这条边框要么来自:-导航栏的底部边框-- tableview的顶部边框--可能是从节标头(但似乎不太可能)的分隔符-- GradientView的底部边框

有人知道是什么导致了这条线吗?
我尝试用:ViewController删除它:
override func viewDidLoad() {
// self.tableview.separatorStyle = .none
// self.tableview.layer.borderWidth = 0
// self.view.layer.borderWidth = 0
}GradientView:
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
self.layer.borderWidth = 0
}SectionHeader:
self.separatorInset.left = 1000
self.layer.borderWidth = 0有什么想法吗?
发布于 2018-01-11 21:18:32
导航栏有一个图像视图,其行在小于或等于1 1px之间,您必须遍历NavigationController navigationBar来查找imageView并将其设置为隐藏。
您可以直接在navigationBar上循环并找到所有的subViews,或者如果您想要对视图有一个引用,那么在这里我将如何完成它。
var lineImageView: UIImageView? = { [unowned self] in
// guard is great try to use it whenever you can
guard let navigationBar = self.navigationController?.navigationBar else {
return nil
}
return self.findLineImageView(for: navigationBar)
}()现在,将这个函数循环起来,直到它找到一个imageView并返回到我们的lineImageView
// remember even **navigationBar** is a UI remember **UINavigationBar**
func findLineImageView(for view: UIView) -> UIImageView? {
// as I said above the line is not more than 1px so we look for a view which is less than or equals to 1px in height
if view is UIImageView && view.bounds.size.height <= 1 {
return (view as! UIImageView)
}
// we loop till we find the line image view and return it
for subview in view.subviews {
if let imageView = findLineImageView(for: subview) {
return imageView
}
}
// if there is no imageView with that height we return nil that's why we return an optional UIImageView
return nil
}现在是魔法部分。在viewWillApear中,将lineImageView设置为隐藏
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
// remember as I said the lineImageView we returned an optional that's why it has question mark which means we are safe
lineImageView?.isHidden = true
}https://stackoverflow.com/questions/48215349
复制相似问题