Customize empty cells in a table view

2019-08-21 20:10发布

问题:

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?

EDIT

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

回答1:

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.

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.