我正在寻找一个带有重叠单元格的 uitableview,如下图所示。问题是,即使我为单元格的内容视图设置了 clipsToBounds = NO,单元格假标题(例如,与前一个单元格重叠的西班牙语)也不会显示。
有谁知道如何解决这个问题?
这是我的代码:
- (UITableViewCell *)tableviewCellTournamentWithReuseIdentifier:(NSString *)identifier andPosition:(NSInteger)pos {
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
if (pos == 0) {
cell.clipsToBounds = NO;
cell.contentView.clipsToBounds = NO;
cell.frame = CGRectMake(0, 0, tournamentsTableView.frame.size.width, CELL_HEIGHT);
UIView* row = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tournamentsTableView.frame.size.width, CELL_HEIGHT)];
row.clipsToBounds = NO;
row.backgroundColor = [UIColor clearColor];
UIView* topRow = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 10)];
topRow.backgroundColor= [UIColor colorWithRed:210/255.0 green:131/255.0 blue:62/255.0 alpha:1.0];
[row addSubview:topRow];
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 10, row.frame.size.width, CELL_HEIGHT-10)];
label.backgroundColor = [UIColor colorWithRed:63*pos/255.0 green:71*pos/255.0 blue:113/255.0 alpha:1.0];
label.font = [UIFont fontWithName:@"HelveticaNeue" size:14];
label.tag = TOURNAMENT_NAME;
label.layer.cornerRadius = 5;
[row addSubview:label];
[cell.contentView addSubview:row];
} else {
cell.clipsToBounds = NO;
cell.contentView.clipsToBounds = NO;
cell.frame = CGRectMake(0, -10, tournamentsTableView.frame.size.width, CELL_HEIGHT);
UIView* row = [[UIView alloc] initWithFrame:CGRectMake(0, -10, tournamentsTableView.frame.size.width, CELL_HEIGHT)];
row.clipsToBounds = NO;
row.backgroundColor = [UIColor clearColor];
UIView* topRow = [[UIView alloc] initWithFrame:CGRectMake(0, -10, 100, 10)];
topRow.backgroundColor= [UIColor colorWithRed:210/255.0 green:131/255.0 blue:62/255.0 alpha:1.0];
[row addSubview:topRow];
[cell bringSubviewToFront:tournamentsTableView];
UILabel* label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, row.frame.size.width, CELL_HEIGHT-10)];
label.backgroundColor = [UIColor colorWithRed:63*pos/255.0 green:71*pos/255.0 blue:113/255.0 alpha:1.0];
label.font = [UIFont fontWithName:@"HelveticaNeue" size:14];
label.tag = TOURNAMENT_NAME;
label.layer.cornerRadius = 5;
[row addSubview:label];
[cell.contentView addSubview:row];
}
return cell;
}
结果是: