我想设置2完全不同的外观(和内容)的细胞。 (一个选择,且一个未选择的)。
此代码的工作,但,因为对于所选择的小区的图像为50%透明,我可以看到底部的BackgroundView。
在清晰,selectedBackgroundView提供了一个很好的方式选择时,填充单元唯一可见的细胞。 难道还有比BackgroundView来填充单元格,怎么也不会出现在selectedBackgroundView位置的另一个位置
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *cellIdentifier = @"hello";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
}
UIImage *image = [UIImage imageNamed:@"listview_btn.png"];
UIImage *imageThumb = [UIImage imageNamed:@"01_thumb.jpg"];
UIImageView* imageView = [[UIImageView alloc] initWithImage:imageThumb];
[imageView setFrame:CGRectMake(0, 0, 50, 67)];
[cell setBackgroundView:[[UIImageView alloc]initWithImage:image] ];
[cell.backgroundView addSubview:imageView];
UIImage *imageSel = [UIImage imageNamed:@"listview_btn_on.png"];
UIImage *imageThumbSel = [UIImage imageNamed:@"01_thumb_Sel.jpg"];
UIImageView* imageViewSel = [[UIImageView alloc] initWithImage:imageThumbSel];
[imageViewSel setFrame:CGRectMake(110, 0, 50, 67)];
[cell setSelectedBackgroundView:[[UIImageView alloc]initWithImage:imageSel] ];
[cell.selectedBackgroundView addSubview:imageViewSel];