2010-05-25 60 views
0

我想爲TableView行單元格放一些背景圖片。我使用下面的代碼:iPhone:如何設置tablerow cell的背景圖片?

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

.....................

........... ........
UIImage * backgroundImage = [UIImage imageNamed:@「cell.png」]; UIColor * backgroundColor = [[UIColor alloc] initWithPatternImage:backgroundImage];
cell.opaque = NO;

cell.contentView.opaque = NO;

cell.backgroundColor = [UIColor clearColor];

cell.backgroundColor = backgroundColor;

//cell.contentView.backgroundColor = [UIColor clearColor];

//cell.contentView.backgroundColor = backgroundColor;

}

但它沒有正確地給出背景圖像。有人可以指導我設置tableview行的背景圖像的正確方法是什麼? 注:我還設置背景圖片爲我的TableView以及使用下面的代碼:

UIImage * backgroundImage = [UIImage imageNamed:@"Tablebackground.png"]; 
UIColor *backgroundColor = [[UIColor alloc] initWithPatternImage:backgroundImage]; 
self.myTableView.backgroundColor = [UIColor clearColor]; 
self.myTableView.alpha = 0.9; 
self.myTableView.backgroundColor = backgroundColor; 

我不遵守的實現代碼如下背景任何問題。這裏唯一的一點是,tableview背景圖像不是靜態的,當滾動發生時,圖像也在滾動。

但我想知道如何爲Tableview行單元格設置背景圖像?

謝謝。

+0

可能重複[iPhone?如何爲tablerow的小區設置背景圖片](http://stackoverflow.com/問題/ 2903911/iphonehow到設置背景圖像換tablerow的細胞) – 2010-05-25 11:29:30

回答