[英]iPhone:How to set background image for tablerow cell?
我想為TableView行單元格放置一些背景圖像。 我正在使用以下代碼:
- (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背景圖像不是靜態的,滾動發生時,圖像也在滾動。
但是我想首先知道如何為Tableview行單元格設置背景圖像?
謝謝。
這是迄今為止我閱讀過的有關UITableView定制的最佳教程: http : //cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.