❌ 현재 섹션간의 간격을 늘리고자 아래와 같이 했으나.. 적용안됨
일정표 섹션과 진행 중인 계획 섹션 간의 간격이 늘어나지 않음..
extension HomeViewController: UITableViewDelegate, UITableViewDataSource {
...
// ✅ 섹션 높이 설정
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 30 // 섹션 간 간격
}
}
🔨 해결 방법
heightForFooterInSection을 사용해서 섹션 간 간격을 늘리는 건 일반적으로 맞는 방법
하지만 UITableView의 grouped 스타일에서는 기본적으로 푸터 높이가 적용되지 않는 경우가 있어서, 추가적으로 viewForFooterInSection을 활용
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return 100 // 섹션 간 간격
}
func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
let spacerView = UIView()
spacerView.backgroundColor = .clear // 투명한 뷰 추가
return spacerView
}
💡 이유
- heightForFooterInSection만 설정하면 grouped 스타일에서는 적용되지 않는 경우가 있음.
- viewForFooterInSection을 추가하면 실제로 빈 푸터 뷰가 생성되어야 적용됨.