Khi tôi đặt UITableViewCells backgroundColor
thành màu bán trong suốt, có vẻ tốt, nhưng màu không bao phủ toàn bộ ô.Nền trong suốt UITableViewCell (bao gồm imageView/accessoryView)
Khu vực xung quanh imageView
và accessoryView
đang mọc lên như [UIColor clearColor]
...
Tôi đã cố gắng thiết lập một cách rõ ràng cell.accessoryView.backgroundColor
và cell.imageView.backgroundColor
là màu giống như các tế bào của backgroundColor
, nhưng nó không hoạt động. Nó đặt một hộp nhỏ xung quanh biểu tượng, nhưng không mở rộng để lấp đầy cạnh trái. Cạnh phải có vẻ không bị ảnh hưởng bởi điều này.
Làm cách nào để khắc phục sự cố này?
EDIT: Đây là mã ô trong bảng liệu:
- (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;
}
thực sự tôi phải làm thêm 1 điều nữa. Cell.textLabel.backgroundColor cần được thiết lập * SAU * màu nền của ô. Tôi KHÔNG có ý tưởng tại sao tôi cần phải làm điều này, nhưng bây giờ nó hoạt động. Cảm ơn Mike! –