gpt4 book ai didi

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

转载 作者:太空狗 更新时间:2023-10-30 03:40:52 26 4
gpt4 key购买 nike

我已将自定义背景图片添加到我的 UITableView 中,它显示正常。然后,我从单元格中删除了任何背景颜色。现在我希望在表格的背景图像之上只看到单元格的文本,但是我看到了奇怪的行为。单元格采用表格背景图像的图案颜色,以便我看到图片中的波浪:

enter image description here

背景图像外壳看起来像这样:

enter image description here

*注意单元格下方消失的白色圆圈!

我的代码如下:在 viewDidLoad 中,我设置了表格 View 的背景图片:

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];
  • 行分隔符是添加到单元格的自定义图像。

最佳答案

尝试设置背景 View ,而不是设置 tableview 的 BackgroundColor 属性:

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

这应该可以解决单元格采用与背景相同的图像的问题。

关于iphone - UITableView 单元格采用 UITableView 背景图像的图案颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6488779/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com