2011-08-26 134 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]; 
相關問題