簡體   English   中英

UITableView單元格采用UITableView背景圖像的圖案顏色

[英]UITableView cell takes pattern color of UITableView's background image

我已經為我的UITableView添加了自定義背景圖像,它顯示正常。 比,我從細胞中刪除了任何背景顏色。 現在我希望在桌子的背景圖像上只看到單元格的文本,但是我看到了奇怪的行為。 單元格采用表格背景圖像的圖案顏色,這樣我就可以看到圖片中的波形:

在此輸入圖像描述

背景圖像shell看起來像這樣:

在此輸入圖像描述

*注意在細胞下消失的白色圓圈!

我的代碼如下:在viewDidLoad中我設置了表視圖的背景圖像:

self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"general_bg.png"]];

對於每個單元格我刪除任何背景顏色,如下所示:

UIView *bckView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
bckView.backgroundColor = [UIColor clearColor];
cell.backgroundView = bckView;

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

UILabel *textLabel = [[UILabel alloc] initWithFrame:CGRectMake(x,y,x1,y1)];
textLabel.backgroundColor = [UIColor clearColor];
[cell.contentView addSubview:textLabel];
  • 行分隔符是添加到單元格的自定義圖像。

不要設置tableview的BackgroundColor屬性,而是嘗試設置backgroundview:

UIView *background = [[UIView alloc] initWithFrame:self.tableView.bounds];
background.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"YOUR_IMAGE.png"]];
self.tableView.backgroundView = background;

這應該可以解決單元格與背景拍攝相同圖像的問題。

self.tableView.backgroundView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"YOUR_IMAGE.png"]];

也許這就是你要找的東西

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM