【发布时间】:2009-10-01 04:55:54
【问题描述】:
当我将 UITableViewCells backgroundColor 设置为半透明颜色时,看起来不错,但颜色并没有覆盖整个单元格。
imageView 和 accessoryView 周围的区域将变为 [UIColor clearColor]...
我已尝试将cell.accessoryView.backgroundColor 和cell.imageView.backgroundColor 显式设置为与单元格的backgroundColor 相同的颜色,但它不起作用。它在图标周围放置了一个小框,但不会扩展以填充左边缘。右边缘似乎不受此影响。
我该如何解决这个问题?
编辑:这是原始表格单元格代码:
- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
cell.opaque = NO;
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.backgroundColor = [UIColor colorWithRed:.1 green:.1 blue:.1 alpha:.4];
cell.textColor = [UIColor whiteColor];
}
cell.imageView.image = [icons objectAtIndex:indexPath.row];
cell.textLabel.text = [items objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
【问题讨论】:
标签: iphone iphone-sdk-3.0 uitableview