代码之家  ›  专栏  ›  技术社区  ›  Nick

更改单个UITableView单元格的UITableView SeparatorColor

  •  9
  • Nick  · 技术社区  · 14 年前

    我有一个 UITableView 使用各种各样的习俗 UITableViewCells .

    我希望能够让这些表格单元格中的一个以不同于其他单元格的分隔符颜色显示。

    我知道 tableview.seperatorColor 更新整个 tableView . 是否有我缺少的特定于单元格的属性或其他方法来执行此操作?

    谢谢你给我小费。抱歉,如果我只是在 UITableViewCell 班级。

    3 回复  |  直到 9 年前
        1
  •  9
  •   nekno    12 年前

    UITableViewCell

    UITableView.separatorColor UITableView

    tableView.separatorColor tableView:cellForRowAtIndexPath:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    switch (indexPath.section) {
        case 0:
            tableView.separatorColor = nil;
            break;
        case 1:
            switch (indexPath.row) {
                case 0:
                    tableView.separatorColor = nil;
                    break;
                case 1:
                    tableView.separatorColor = [UIColor clearColor];
                    break;
                default:
                    break;
            }
            break;
        default:
            break;
    }
    
        2
  •  8
  •   mipe34 shivbits    12 年前

    tableView.separatorColor

    separatorStyle UITableViewCellSeparatorStyleNone UITableViewCell

    contentView Cell

        3
  •  4
  •   Leszek Szary    10 年前

    1. UITableViewCellSeparatorStyleSingleLine
    2. cell.separatorInset = UIEdgeInsetsMake(0, 0, 0, 10000);
    3. cell.backgroundColor = [UIColor greenColor];