2012-03-27 73 views
0

我一直在使用默认颜色灰色和蓝色的单元格选择,但我想尝试一个明亮的橙色,但我不知道如何做自定义的UITableview选择。自定义selectionStyle颜色为uitableviewcell

这是我使用此刻的代码..

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
cell.selectionStyle = UITableViewCellSelectionStyleGray; 

我也曾尝试

[cell setSelectionStyle:[UIColor orangeColor]]; 

,但我得到一个警告说setSelectionStyle不是整数的东西。

回答

1

你会得到该错误,因为程序期望UITableViewCellSelectionStyle你给它一个UIColor。我不知道是否有办法以编程方式做到这一点,但你可以尝试使用单元格的selectedBackgroundView财产使用自己的形象:

cell.selectedBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"yourImageHere.png"]] autorelease]; 

这会去你的cellForRowAtIndexPath方法。