您必须使用此委托设置单元格背景:-
- (void)tableView: (UITableView*)tableView
willDisplayCell: (UITableViewCell*)cell
forRowAtIndexPath: (NSIndexPath*)indexPath
{
// UIImage *img = [UIImage imageNamed:@"button.png"]; // get your background image
UIColor *cellBackgroundColor = [UIColor colorWithRed:255/255.0 green:108/255.0 blue:61/255.0 alpha:1.0]; //if you want to set color then use this line
// UIColor *backgroundColor = [[UIColor alloc] initWithPatternImage: img];
cell.backgroundColor = cellBackgroundColor;
cell.textLabel.backgroundColor = [UIColor clearColor];
cell.detailTextLabel.backgroundColor = [UIColor clearColor];
}
你的桌子看起来像: -
获取 RGB 颜色并在 iPhone 上使用 UIColor 对其进行标准化
Your values are between 0 and 255. Use them to create a UIColor:
float r; float g; float b; float a;
[UIColor colorWithRed:r/255.f
green:g/255.f
blue:b/255.f
alpha:a/255.f];