如何从分组的UITableView的单元格中删除边框?
问题描述:
在底部的小白色条纹真的抛出了设计,我似乎无法弄清楚如何删除它。
This问题有一个高额定应答说要做到这一点:
cell.backgroundView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
但是,这(与setBackgroundColor:
集)移除了我的背景,灰色以及因此它也不能工作。
答
添加到您的viewDidLoad:
删除表格的边框:
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
我不明白你的问题非常好,但我建议你检查你的背景视图的高度,就像一个测试把图像作为单元格的背景图,并检查白线剧照有:
cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"imageName.png"]]autorelease];
// -----
您提供的代码不工作贝科使用您正在创建一个新的空白的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;
}
答
试试吧
self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
+3
有一点解释会很有用! :) – Parris 2013-04-07 23:45:56
你的第一个代码的建议优美的工作。谢谢。 – user212541 2013-04-07 23:28:25
好吧,我很高兴帮助你'user212541',检查我的编辑,知道你为什么提供的代码不工作! – Mateus 2013-04-07 23:29:35
你是最棒的;谢谢。 – user212541 2013-04-08 00:25:38