分隔符一个单元格的颜色

时间:2014-12-15 19:57:15

标签: objective-c uitableview

如何更改表格视图的分隔线颜色?但我只想改变第一行。

这适用于整个tableview。

tableView.separatorColor = [UIColor blueColor];

2 个答案:

答案 0 :(得分:2)

  1. UITableViewCell的子类,并在单元格的顶部放置一行UIView,可以通过属性访问(在故事板或代码中,无论你喜欢什么)
  2. cellForRowAtIndexPath中根据行设置线条视图的颜色。
  3. 如果您只想更改第一行,那么您指的是第一行而不是第一行和第二行之间的行,那么请考虑使用UITableView' tableHeaderView

答案 1 :(得分:-1)

试试这个

 override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
        if indexPath.row == 0 {
            tableView.separatorColor = UIColor.blueColor()
        } else {
            tableView.separatorColor = UIColor.greenColor()
        }
    }
相关问题