在表视图中自定义空单元格 [英] Customize empty cells in a table view

查看:121
本文介绍了在表视图中自定义空单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表视图,我想在其中更改单元格的背景。这可以通过继承UITableViewCell并在Interface Builder中设置单元格类来完成,但这不会改变用于填充表格视图的单元格的背景。例如。如果我只有八个单元格,那么可以添加九个单元格以用单元格填充表格视图。

I have a table view in which I would like to change the backgrounds of the cells. This can be done by subclassing UITableViewCell and setting the class of the cells in Interface Builder but this will not change the background of the cells used to "fill up" the table view. E.g. if I only have eight cells, then nine cells may be added to fill up the table view with cells.

有没有办法改变这些空单元格的背景?

Is there any way to change the background of these empty cells?

编辑

这不是静态表视图的问题。这适用于所有表视图。如何自定义空单元格的背景?

This is not an issue regarding static table views. This applies to all table views. How to customize the background of an empty cell?

推荐答案

我真正想要的是复制iPad设置应用程序的外观。我意识到Apple只是隐藏了分隔符,并没有为它们的空单元设置背景。这就是我最终要做的事情。

What I really wanted was to replicate the look of the iPad Settings app. I realized that Apple just hides the separators and does not set a background on their "empty" cells. This is what I ended up doing.

在表格视图上设置页脚然后将此页脚的高度设置为0.1f将隐藏页脚而不显示任何单元格低于它。

Setting a footer on the table view and then setting the height of this footer to 0.1f will hide the footer and not show any cells below it.

这篇关于在表视图中自定义空单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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