I want to reduce the height between sections. I searched for existing issues here and found this and this. But neither of them worked for me.
I was able to whip up a solution using those answers. But I was hoping it would be nice to have this functionality accessible directly as I've shown below rather than achieving it through workarounds.
form
+++ Section() { section in
section.header?.height = { 10 }
section.footer?.height = { 10 }
}
Hey @Isuru-Nanayakkara , this is the proper way to change the space between sections.
Aa a workaround you can implement a global function to do so for each row.
func Section10() -> Section{
return Section() { section in
section.header?.height = { 10 }
section.footer?.height = { 10 }
}
}
Hi Martin,
I'm trying your solution right now but setting section.header?.height = { 10 } doesn't actually change the header height.
I've also tried the following setup and all it does is just add a white view of the height 20, but it's fit in the lower part of the header view which is otherwise - the standard size and color:
form =
form +++
PushRow<CitiesList>("City") {
$0.title = $0.tag
$0.options = CitiesList.allValues
$0.value = .NewYork
}.onPresent({ (_, vc) in
vc.enableDeselection = false
})
+++ Section() { section in
section.header = {
var header = HeaderFooterView<UIView>(.callback({
let view = UIView(frame: CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: 20))
view.backgroundColor = .white
return view
}))
header.height = { 20 }
return header
}()
}
I am having the same issue as drinkus. The header view WILL NOT change height no matter what I try.
+++ Section(){ section in
var header = HeaderFooterView<UILabel>(.Class)
header.onSetupView = {view, _, _ in
view.textColor = Helpers().getMainTintColor()
view.text = "Basic Info"
//view.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
view.font = UIFont.systemFontOfSize(20)
}
//header.height = { 100.0 }
section.header = header
}
tried setting header & footer height with .leastNormalMagnitude, there is still a 15 px space between each section. It didn't work if I want to set the space smaller, eg: 8px. I have to use xlform implementation which is to override the delegation method for the vc:
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return .leastNormalMagnitude
}
override func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return
}
I don't know why I cannot set a space lesser than 10px between sections for grouped tableview
For this solution to work you must specify an empty string header and footer text:
let section = Section(header: "", footer: "")
section.header?.height = { CGFloat.leastNormalMagnitude }
section.footer?.height = { CGFloat.leastNormalMagnitude }
Most helpful comment
For this solution to work you must specify an empty string header and footer text: