如何将分组的UITableView单元格的背景更改为黑色(或非白色)? [英] How to change a grouped UITableView cell's background to black (or non-white)?

查看:104
本文介绍了如何将分组的UITableView单元格的背景更改为黑色(或非白色)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想确保我不会忽视明显的东西...似乎应该是微不足道的将UITableView的单元格的背景颜色(黑色是好的)设置为非白色或完全透明的东西,可以用白色文本显示您的数据。然而,随着我的尝试,我失去了我的分组表视图的角落,它看起来像垃圾。

Just want to make sure I'm not overlooking something obvious... It seems like it should be trivial to set the background color (black is fine) of a UITableView's cell to something other than white or completely transparent so that you can display your data with white text. However, with my attempts I lose the corners on my grouped table view and it all looks like crap.

我见过&了解 Matt Gallagher 关于自定义TableView单元格的方法异国情调的渐变等,但想要确定之前沿着这条路径...

I've seen & understand the methods described by Matt Gallagher about customizing TableView cells with exotic gradients, etc. but wanted to be certain before heading down that path...

推荐答案

我相信圆角分组样式实际上是表格单元格的背景。因此,你不能只是替换白色部分,因为它不是纯色的绘制边框 - 它的ImageView充当单元格的backgroundView(使用不同的图形,取决于单元格行和部分行数)。

I believe that the rounded corners of the Grouped style are actually backgrounds of the table cells. Thus you can't just replace the white part, because it's not solid color with drawn border - it's ImageView acting as backgroundView for the cell (using different graphics depending of the cell row and number of rows in section).

所以,你试着用你自己的图形,所以你可以保持圆形(我正在尝试的东西出来为自己,还没有完全搞定)或将每个cell.backgroundView设置为nil,并使用单元格.backgroundColor = [UIColor blackColor];

So either you try with your own graphics so you can keep the roundness (I'm trying something out for myself, not fully figured yet) or set each cell.backgroundView to nil and use cell.backgroundColor = [UIColor blackColor];

这篇关于如何将分组的UITableView单元格的背景更改为黑色(或非白色)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆