繁体   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