セルの 2 つの完全に異なる外観 (およびコンテンツ) をセットアップしたいと考えています。(1 つは選択され、もう 1 つは選択されていません)。
このコードは機能しますが、選択したセルの画像が 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];