【问题标题】:Get rid of line above UITableView摆脱 UITableView 上方的行
【发布时间】:2013-01-09 03:50:46
【问题描述】:

我有一个UITableView(恰好有一个UISearchBar)并且似乎无法弄清楚如何摆脱它上面的白色/灰色边框。我需要在UISearchBar 和它上面的黑色之间有无缝的黑色。

我曾尝试隐藏UISearchBar 以查看是否与它有关,但这条线仍然出现。

有什么想法吗?

【问题讨论】:

    标签: ios uitableview border line uisearchbar


    【解决方案1】:

    就我而言,它有助于设置:

        searchBar.clipsToBounds = YES;
    

    【讨论】:

    • 实际上这就是为我解决的问题。搜索栏无缘无故地在顶部出现一行!
    • 它不适用于 uitableviewcontroller。我不得不改用 uiviewcontroller。
    【解决方案2】:

    您必须根据您的要求自定义 UISearchBar 背景以匹配。,take a look at this tutorial.

    【讨论】:

    • 我曾尝试使用图像作为 UISearchBar 的背景,但这不起作用 - 它确实是具有该行的 UITableView 的顶部。我还尝试了以下方法:[code] [self.searchBar setBarStyle:UIBarStyleBlackTranslucent]; self.searchBar.backgroundColor = [UIColor blackColor]; for (id img in self.searchBar.subviews) { if ([img isKindOfClass:NSClassFromString(@"UISearchBarBackground")]) { [img removeFromSuperview]; } }[/code]
    【解决方案3】:

    您应该试试这个,通过它您可以设置单元格边框的颜色,如果您想更改特定单元格边框的颜色,请将其设置为:if (indexPath.row == yourcell):

    tableView.separatorColor = [UIColor blackColor];
    

    上述方法也必须放在表格视图数据源的 CellForRowAtIndexPath 方法中。

    如果有效请通知..

    【讨论】:

    • 这确实将分隔符颜色更改为黑色,但是 tableview 顶部的线仍然是灰色的。
    【解决方案4】:

    这与我使用的 pullToRefresh 视图有关(使用 SensibleTableView)——它在 drawRect 中有一些代码来绘制线条。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-09
      相关资源
      最近更新 更多