我已創建自定義單元格。並且我有分組樣式的表格視圖。現在,我想將背景圖像放到不同部分的每個單元格中。如何設置自定義單元格的背景圖像。 這裏是創建自定義單元格的代碼。如何在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 –