有人可以告訴我爲什麼這不工作正確嗎?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