加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-14 19:52:02 所属栏目:百科 来源:网络整理
导读:我已经为我的UITableView添加了自定义背景图像,它显示正常.比,我从细胞中删除了任何背景颜色.现在我希望在桌子的背景图像上只看到单元格的文本,但是我看到了奇怪的行为.单元格采用表格背景图像的图案颜色,这样我就可以看到图片中的波形: 背景图像shell看起
我已经为我的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;

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读