我希望整个单元格以蓝色打印,但它只显示一个小带。如何在TableView上设置单元格的颜色?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
[cell.contentView setBackgroundColor:[UIColor blueColor]];
cell.textLabel.text = [NSString stringWithFormat:@"%@", [cat objectAtIndex:indexPath.row]];
return cell;}
我的屏幕捕获是这样的:
试试这个http://stackoverflow.com/questions/6346721/uitableviewcell-background-color-problem – 2013-05-08 11:59:37