有人可以告诉我为什么这不工作正确吗?UIView背景颜色不生效
我的表格视图单元格中有以下代码行,用于tableView:didSelectAtIndexRowPath:
方法。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[[tableView viewWithTag:199]removeFromSuperview];
CGSize cellSize = [tableView cellForRowAtIndexPath:indexPath].frame.size;
UIView *subSelectionView = [[UIView alloc]initWithFrame:CGRectMake(10, 0, (int)cellSize.width - 20, 100)];
[subSelectionView setBackgroundColor:[UIColor blueColor]];
subSelectionView.layer.borderColor = [UIColor grayColor].CGColor;
subSelectionView.layer.borderWidth = 1;
subSelectionView.tag = 199;
[[tableView cellForRowAtIndexPath:indexPath]addSubview:subSelectionView];
}
注意代码:
[subSelectionView setBackgroundColor:[UIColor blueColor]];
很明显,我想改变,我加入到UITableViewCell
子视图的颜色,而是它为什么不工作?
确保'subSelectionView'不被表格视图单元格的内容视图覆盖,因为这似乎是发生了什么。 – Costique 2012-01-31 05:10:04