如何从分组的UITableView单元格中删除边框?

use*_*541 1 objective-c uitableview uiview ios

在此输入图像描述

底部的小白色条纹真的抛弃了设计,我似乎无法弄清楚如何去除它.

这个问题有很高的评价响应,据说这样做:

cell.backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
Run Code Online (Sandbox Code Playgroud)

但是这也从我的背景中删除了灰色(设置为setBackgroundColor:)所以它也不起作用.

Mat*_*eus 7

将其添加到您viewDidLoad:的表格边框:

self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
Run Code Online (Sandbox Code Playgroud)

我没有很好地理解你的问题,但我建议你检查单元格背景视图的高度,就像测试将图像作为单元格背景视图并检查白线是否仍在那里:

cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imageName.png"]]autorelease];
Run Code Online (Sandbox Code Playgroud)

// -----

您提供的代码无法正常工作,因为您正在创建一个新的空白UIView并将其设置为单元格背景!正确的方法如下:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *CellIdentifier = @"ApplicationCell";

    UITableViewCell *cell = (UITableViewCell *)[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

        UIView *myBackgroundView = [[UIView alloc] init];
        myBackgroundView.frame = cell.frame;
        myBackgroundView.backgroundColor = [UIColor greenColor]; <== DESIRED COLOR

        cell.backgroundView = myBackgroundView;

    }

    return cell;

}
Run Code Online (Sandbox Code Playgroud)