Sobreposição de visualizações de conteúdo do UITableViewCell
Eu tenho essa tabela cujas células são assim:
Como você pode ver, a borda superior de cada célula deve se sobrepor à célula acima. Agora, essa borda faz parte do plano de fundo (sem sobreposição até agora).
Agora, eu separei a borda do fundo e o código de criação da minha célula ficou assim:
<code>#define QAImage(NAME) [[[UIImageView alloc] initWithImage:[UIImage imageNamed:NAME]] autorelease] - (UITableViewCell*) tableView:(UITableView*)table cellForRowAtIndexPath:(NSIndexPath*)index { UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"Entry"]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Entry"] autorelease]; cell.backgroundView = QAImage(@"bg-cell.png"); cell.selectedBackgroundView = QAImage(@"bg-cell-sel.png"); cell.selectionStyle = UITableViewCellSelectionStyleGray; UIImageView *img = QAImage(@"disclosure.png"); img.highlightedImage = [UIImage imageNamed:@"disclosure-sel.png"]; cell.accessoryView = img; CGRect r = cell.frame; r.size.height = table.rowHeight; r.size.width = table.frame.size.width; cell.frame = r; r = cell.contentView.frame; r.origin = CGPointMake(13, 13); r.size.width -= 8 + img.frame.size.width; r.size.height -= 25; [cell.contentView addSubview:[[[TagView alloc] initWithFrame:r] autorelease]]; img = QAImage(@"cell-top.png"); img.highlightedImage = [UIImage imageNamed:@"cell-top-sel.png"]; img.opaque = NO; r = img.frame; r.origin = CGPointMake(0, 1 - r.size.height); // The (supposed) overlapping happens here. img.frame = r; cell.contentView.clipsToBounds = NO; [cell.contentView addSubview:img]; } // Here I set the title. (omitted) return cell; } </code>
O problema é,a borda só é mostrada quando estou rolando na mesacaso contrário, ele é sobreposto pela célula acima dele. (O caminho errado ao redor.)
eu tentei[cell setNeedsDisplay]
em-tableView:willDisplayCell:forRowAtIndexPath:
, adicionando a borda (cell-top.png
) toda vez que uma célula é solicitada (o que obviamente leva a múltiplos desenhos e não parece boa; independente disso, ainda não resolve o problema) e definindoimg.layer.zPosition = 2
.
Como posso forçar esse UIImageView a ficar no topo o tempo todo?