2013-06-11 45 views

回答

0

在的tableView數據源的方法

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

你可以這樣做:

UIImageView * imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image_background.png"]]; 
cell.selectedBackgroundView = imageView; 

當選中單元格時,其背景設置爲imageView

+0

使用'

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

我知道如何做到以上.....但我想圖像重疊整個單元格,並且其寬度比整個單元格更大 – Jatin

+0

請參閱上面的編輯..附圖 – Jatin

0

如果你不使用任何背景圖片爲您UITableViewCell比使用delegate method of的UITableView:如果您使用的背景圖片爲您UITableViewCellcellForRowAtIndexPath:

UIImageView *selBGView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"urimage.png"]]; 
cell.selectedBackgroundView = selBGView; 
+0

請參閱我的編輯以上.. .. ge附上 – Jatin

相關問題