使用故事板设置 tableview 静态单元格的行间距

set line spacing of static cells of tableview with storyboard

我想知道是否有办法设置带有故事板的 tableview 静态单元格的行间距。

我没有找到这样做的归因者:

我想设置行间距,应该是这样的:

属性检查器中没有可执行此操作的内容,您可以这样做

contentView
     topView   ----- height(static) ---- white background
     spaceView ----- height (5) ---- gray background

你不能那样做。有几种方法可以解决这个问题。

  1. 模拟单元格本身中的分隔符(例如,参见 )。

  2. 使用每隔一个单元格作为分隔符(因此第 0 行的单元格将是普通单元格,第 1 行的单元格将是分隔符,第 2 行的单元格将是普通单元格,等等)。

  3. 使用部分页脚作为分隔符,在这种情况下,每个单元格都会有部分 - numberOfSections 将 return 所有单元格的数量,numberOfRows 将return 1. 然后用footerForSection提供合适的"separator".

使用UICollectionView

UITableView 不提供行间距