我知道这可能很明显,但我没有将背景设置为IB中的任何颜色.我的代码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;
}
Run Code Online (Sandbox Code Playgroud)
我得到的是这个:

默认情况下,单元格背景为黑色,直到我单击它以查看其文本.我错过了什么吗?
您需要设置标签的背景和单元格的背景:
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.contentView.backgroundColor = [UIColor clearColor];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2618 次 |
| 最近记录: |