这个问题很简单,但很烦人。我在视图控制器中放置了一个分组样式的UITableView,并使控制器成为表视图的委托和数据源。自定义UITableView背景颜色
当我什么改变表格的背景颜色,我用:
UIColor *backColor = [UIColor colorWithRed:(15.0/255.0) green:(170.0/255.0) blue:(230.0/255.0) alpha: 0.75f];
[self.myTable setBackgroundColor:backColor];
和tableView:tableView cellForRowAtIndexPath:indexPath
方法,我只返回一个简单的细胞:
static NSString *CellIdentifier = @"CellIdentifier";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil){
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:moreCellIdentifier] autorelease];
}
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
return cell;
但奇怪事情是在每个单元格的圆角处颜色是不正确的,我认为这是因为单元格的其中一个子视图的框架大于单元格,我试图使子视图的框架很小但仍然失败任何想法?谢谢。
我认为这是单元格宽度的问题,我将UITableViewCell分类并使宽度仅为200的新单元类,但在表格视图中单元格仍占用几乎整个屏幕宽度。 – joe522 2011-06-10 17:40:53