【问题标题】:How to set separator of one section of tableView to clear如何将tableView的一个部分的分隔符设置为清除
【发布时间】:2013-04-22 17:59:49
【问题描述】:

我的 tableView 中有四个部分,我只希望最后一个部分有一个清晰的分隔符。我知道如何为整个 tableView 执行此操作,但找不到我的问题的任何解决方案。我想到的唯一解决方案是在 Photoshop 中将单元格创建为图像并将该图像设置为单元格背景。有没有人知道如何在不使用 Photoshop 的情况下做到这一点?

【问题讨论】:

    标签: objective-c uitableview separator


    【解决方案1】:

    试试这个

    查看 didLoad

    tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
        if(cell==nil)
        {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
            UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.bounds.size.width, 1)];
            view.backgroundColor = [UIColor greenColor];
            view.tag = 101;
            [cell addSubview:view];
        }
    
    
        if (indexPath.section == 0)
        {
            [[cell viewWithTag:101] setHidden:YES];
        }
        else if(indexPath.section == 1)
        {
            [[cell viewWithTag:101] setHidden:NO];
        }
        return cell;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-01-21
      • 1970-01-01
      • 2013-08-19
      • 1970-01-01
      • 1970-01-01
      • 2011-10-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多