2009-04-09 54 views

回答

9

當然可以。

有兩種方法來實現這一目標:

  1. 使用UITableViewCellselectedBackgroundViewselectedTextColor性能
  2. 子類UITableViewCell貫徹drawInRectsetSelected:animated:方法

後一種選擇,給你更多靈活性和更好的性能,但如果您之前沒有使用過CoreGraphics,可能會稍微困難一些。

UPDATE爲響應OP的評論:

這裏是你如何使用selectedBackgroundView屬性:

UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 60)]; 
[bgView setBackgroundColor:[UIColor redColor]]; 
[cell setSelectedBackgroundView:bgView]; 
[bgView release]; 

我沒有嘗試這樣做我自己,但它應該工作。

+0

你能說說第一種方法嗎?我試過'cell.selectedBackgroundView.backgroundColor = [UIColor redColor]',但它似乎沒有改變任何東西。 – 2009-04-09 17:49:49

+0

我更新了我的答案。 – 2009-04-09 18:13:02

相關問題