要件
UITableView を Grouped Style にした際、このような余白がヘッダーとフッターの領域にできてしまいます。これを無くしたいです。
| イメージ |
|---|
![]() |
対応
UITableViewDelegate からセクションヘッダーおよびフッターの高さ値を返しますが、ここで CGFloat.leastNormalMagnitude という具合で高さ値を指定してあげれば、例の余白をなくすことができます。
ちなみに return 0.0 や、tableView.sectionFooterHeight = CGFloat.leastNormalMagnitude では効果がありませんでした。
UITableViewDelegate
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return CGFloat.leastNormalMagnitude
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return CGFloat.leastNormalMagnitude
}
| 結果 |
|---|
![]() |

