Ios 带黑色背景的UITableViewCell
我知道这可能很明显,但我没有在IB中将背景设置为任何颜色。我的Ios 带黑色背景的UITableViewCell,ios,uitableview,Ios,Uitableview,我知道这可能很明显,但我没有在IB中将背景设置为任何颜色。我的UITableView代码如下: -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *cellID = @"Cell Identifier"; UITableViewCell *cell = [tableView dequeueRe
UITableView
代码如下:
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellID = @"Cell Identifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if(!cell)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellID];
}
cell.textLabel.text = [_listeDesChapitres objectAtIndex:indexPath.row];
cell.backgroundColor = [UIColor clearColor];
return cell;
}
我得到的是:
默认情况下,单元格背景为黑色,直到我单击它以查看其文本为止。我遗漏了什么吗?使用:
cell.contentView.backgroundColor=[UIColor clearColor];
而不是:
cell.backgroundColor=[UIColor clearColor];
使用:
而不是:
cell.backgroundColor=[UIColor clearColor];
您需要设置标签的背景和单元格的背景:
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor clearColor];
您需要设置标签的背景和单元格的背景:
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor clearColor];