2010-10-18 79 views
2

我們可以更改表視圖的選擇顏色,即單元格,默認情況下它的藍色,所以,我們可以將其更改爲任何其他顏色?更改表視圖的單元格選擇顏色

問候

+0

+1我需要那個問題和平 – 2011-02-04 03:44:31

回答

3

這樣的代碼

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

,或者你可以將其設置在界面生成器爲灰色,我覺得藍色和灰色是所有可用而無需創建一個是視圖

+1

謝謝阿隆,我已經使用這個片段,我不想給圖像,我們不能只是顏色。感謝relpy ...讚賞 – iscavengers 2010-10-18 20:47:53

+1

進一步谷歌搜索引導我到這個http://stackoverflow.com/questions/281515/how-to-customize-the-background-color-of-a-uitableviewcell – 2010-10-18 20:55:39

3

另一種方式來做到這一點,不需要圖像文件是:

UIView *bgView = [[UIView alloc] init]; 
// At least on iOS6 you don't to size the view for this to work. 
bgView.backgroundColor = [UIColor grayColor]; 
aCell.selectedBackgroundView = bgView;