Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.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 是否可以为分组表格中的表格设置颜色_Iphone_Xcode_Grouped Table - Fatal编程技术网

Iphone 是否可以为分组表格中的表格设置颜色

Iphone 是否可以为分组表格中的表格设置颜色,iphone,xcode,grouped-table,Iphone,Xcode,Grouped Table,我知道如何为普通桌子设置颜色。 如果移动到分组表格,背景颜色也将移动,并位于表格本身外部的背景中。 是否也可以设置桌子的颜色。例如,一种颜色用于外部区域,另一种颜色用于表格?这可以通过添加几行代码来完成 对于使用图像作为背景 tableView.opaque = NO; [tableView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]]]; 对于使用单色,您可以使用 ta

我知道如何为普通桌子设置颜色。 如果移动到分组表格,背景颜色也将移动,并位于表格本身外部的背景中。
是否也可以设置桌子的颜色。例如,一种颜色用于外部区域,另一种颜色用于表格?

这可以通过添加几行代码来完成

对于使用图像作为背景

tableView.opaque = NO;
[tableView setBackgroundColor:[UIColor colorWithPatternImage:[UIImage imageNamed:@"image.png"]]];
对于使用单色,您可以使用

tableView.opaque = NO;
    [tableView setBackgroundColor:[UIColor blueColor]]; 

有关更多详细信息,您可以查阅。

对于外部颜色,您可以通过界面生成器或使用

[myTableView setBackgroundColor: [UIColor redColor]];
对于内部颜色,您可以在UITableView数据源方法中设置单元格的背景颜色:

 -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

static NSString * CellIdentifier = @"customCell";
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

if (cell == nil) {
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}

cell.backgroundColor = [UIColor greenColor];

return cell;

}

看看前面的问题,谢谢!如果您投票支持我的答案并选择它作为接受答案,我将不胜感激。这将有助于我们双方建立声誉。现在我把你的答案标记为有用的答案。这就是你的意思吗?你可以对任何答案投赞成票/反对票,这会给回答者带来声誉分数。(你可以在答案开始前使用^v按钮),你通常会投下感谢票。答案前面还有一个复选标记,提问者可以通过点击该复选标记选择任何答案作为所选答案。它为回答者和提问者都提供了声誉分数。当设置一张图片作为背景时,它就像两张图片一样。一个像一个完整的背景,同一张图片像一个框架围绕着我的分组表,紧跟在小格子后面,但另一个背景是固定的。结果是,带有图片的帧在带有相同图片的背景上滑动,看起来有点奇怪。如果没有框架,那就太完美了。你知道怎么解决吗?