UITableView单元格采用UITableView背景图像的图案颜色

Mis*_*sha 6 iphone xcode objective-c uitableview

我已经为我的UITableView添加了自定义背景图像,它显示正常.比,我从细胞中删除了任何背景颜色.现在我希望在桌子的背景图像上只看到单元格的文本,但是我看到了奇怪的行为.单元格采用表格背景图像的图案颜色,这样我就可以看到图片中的波形:

在此输入图像描述

背景图像shell看起来像这样:

在此输入图像描述

*注意在细胞下消失的白色圆圈!

我的代码如下:在viewDidLoad中我设置了表视图的背景图像:

self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"general_bg.png"]];
Run Code Online (Sandbox Code Playgroud)

对于每个单元格我删除任何背景颜色,如下所示:

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];
Run Code Online (Sandbox Code Playgroud)
  • 行分隔符是添加到单元格的自定义图像.

Eth*_*ick 13

不要设置tableview的BackgroundColor属性,而是尝试设置backgroundview:

UIView *background = [[UIView alloc] initWithFrame:self.tableView.bounds];
background.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"YOUR_IMAGE.png"]];
self.tableView.backgroundView = background;
Run Code Online (Sandbox Code Playgroud)

这应该可以解决单元格与背景拍摄相同图像的问题.