简体   繁体   English

更改uitableview的最后一部分下方区域的颜色

[英]Change color of the area below the last section of a uitableview

I have a UITableView. 我有一个UITableView。 I figured out how to change the background color for the section headers. 我想出了如何更改节标题的背景色。 However, it also changes the bottom area that contains "no section/rows" to the same color. 但是,它还将包含“无节/行”的底部区域更改为相同的颜色。 I don't want this. 我不要这个

Is there anyway I can set the color of that area to be a different color than the section headers? 无论如何,我可以将该区域的颜色设置为与节标题不同的颜色吗?

See example picture for more information. 有关更多信息,请参见示例图片。 底部蓝色区域是我想要成为其他颜色的部分

Any help is greatly appreciated. 任何帮助是极大的赞赏。 I've done research but I haven't found anything yet. 我已经做过研究,但还没有发现任何东西。

Basically, what I had to do was: 基本上,我要做的是:

In Interface Builder, change the color of the view to what you want displayed at the bottom. 在Interface Builder中,将视图的颜色更改为要在底部显示的颜色。

I used the same color that I had set for my table cell rows. 我使用与表格单元格行相同的颜色。

For the section headers: 对于节标题:

In the willDisplayHeaderView method, do: willDisplayHeaderView方法中,执行以下操作:

UITableViewHeaderFooterView *header = (UITableViewHeaderFooterView *)view;
header.contentView.backgroundColor = [UIColor blueColor];    

Please note: If you get a white/gray line above the section header - this deals with the footer. 请注意:如果在节标题上方有一条白色/灰色线-这与页脚有关。 So, in viewDidLoad method, set the table footer height to 0: 因此,在viewDidLoad方法中,将表页脚高度设置为0:

self.tableView.sectionFooterHeight = 0.0;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM