I know how to set color to a plain table. If shifting to a grouped table the background color will also shift and be in the background outside the table itself. Is it possible to set color to the table also. I.e. one color for the outside area and another for the table?
Is it possible to set color to the table in a grouped table
148 views Asked by Lars - At
2
There are 2 answers
3
On
For outer color you can set Table background color via interface builder or through code using
[myTableView setBackgroundColor: [UIColor redColor]];
and for Inner color, you can set the background color of the cell in UITableView datasource method:
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString * CellIdentifier = @"customCell";
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
cell.backgroundColor = [UIColor greenColor];
return cell;
}
This can be done by adding a few lines of code.
For using image as background,
For using single color you can use,
For more detail, You can look up this tutorial.