2011-08-26 131 views

回答

1

你可以很容易地改变细胞中选择风格为灰色:

[myTableView setSelectionStyle: UITableViewCellSelectionStyleGray]; 

或者你可以在willDisplayCell委托改变contentView'sbackgroundColor

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath { 
    cell.backgroundColor = [UIColor redColor]; 
} 

另一种方法是创建一个自定义单元格并更改背景的颜色。

+0

感谢),但在init方法内CustomCell类[自我setSelectionStyle:...] –

1
UIView *bgColorView = [[UIView alloc] init]; 
[bgColorView setBackgroundColor:[UIColor redColor]]; 
[cell setSelectedBackgroundView:bgColorView]; 
[bgColorView release]; 

想必你可以做同样的一个UIImageView以及

UIImageView *bgImageView = [[UIImageView imageNamed:@"Your Image"]; 
[cell setSelectedBackgroundView:bgImageView]; 
[bgImageView release]; 
相关问题