Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UITableView单元格的图案颜色为UITableView';背景图像_Iphone_Objective C_Xcode_Uitableview - Fatal编程技术网

Iphone UITableView单元格的图案颜色为UITableView';背景图像

Iphone UITableView单元格的图案颜色为UITableView';背景图像,iphone,objective-c,xcode,uitableview,Iphone,Objective C,Xcode,Uitableview,我已经在UITableView中添加了自定义背景图像,它显示的很好。然后,我从单元格中删除了任何背景色。现在我希望在表格的背景图像上只看到单元格的文本,但我看到了奇怪的行为。单元格采用表格背景图像的图案颜色,因此我可以看到如图所示的波浪: 背景图像外壳如下所示: UIView *bckView = [[[UIView alloc] initWithFrame:CGRectZero] autorelease]; bckView.backgroundColor = [UIColor clearCo

我已经在UITableView中添加了自定义背景图像,它显示的很好。然后,我从单元格中删除了任何背景色。现在我希望在表格的背景图像上只看到单元格的文本,但我看到了奇怪的行为。单元格采用表格背景图像的图案颜色,因此我可以看到如图所示的波浪:

背景图像外壳如下所示:

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];

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

我的代码如下: 在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];
  • 行分隔符是添加到单元格的自定义图像

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

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"]];

也许这就是你要找的

是的。它满足了我的需要。非常感谢。但是,如果有人真的希望tableview的背景颜色是一种模式,而不需要对单元格重复这种模式,该怎么办呢?小建议。现在,在2013年,不要使用神奇的数字
UIView*background=[[UIView alloc]initWithFrame:self.tableView.bounds]