我已创建自定义单元格。并且我有分组样式的表格视图。现在,我想将背景图像放到不同部分的每个单元格中。如何设置自定义单元格的背景图像。 这里是创建自定义单元格的代码。如何在UITableView单元格中设置背景图像?
UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 305, 90)];
// view.backgroundColor = [UIColor darkGrayColor];
UIImageView *imageV = [[UIImageView alloc] initWithFrame:CGRectMake(11, 9, 61, 55)];
// NSLog(@"imageArray%@",[play.imageArray count]);
NSString *img=[play.imageArray objectAtIndex:indexPath.row];
NSLog(@"img=%@",img);
imageV.image = [UIImage imageNamed:img];
[view addSubview:imageV];
[imageV release];
UILabel *lblAchievementName = [[UILabel alloc] initWithFrame:CGRectMake(90, 10, 168, 21)];
lblAchievementName.text = [play.listData objectAtIndex:indexPath.row];
lblAchievementName.backgroundColor=[UIColor clearColor];
lblAchievementName.textColor=[UIColor orangeColor];
[lblAchievementName setFont:[UIFont fontWithName:@"Arial Black" size:16.5]];
[view addSubview:lblAchievementName];
[lblAchievementName release]
[cell.contentView addSubview:view];
return cell;
现在如何设置这个自定义视图的背景图像?
你的表格视图中有多少部分? –
看看这个我以前的答案 http://stackoverflow.com/questions/6329832/uitableview-cell-with-background-image/6330427#6330427 –