[英]Hiding the header and the footer of a section using Eureka forms
I am using Eureka to create a sign-up page. 我正在使用Eureka创建注册页面。 I have a single section.
我只有一个部分。 I would like to hide the header and the footer of the section, and I am not finding a way to do it.
我想隐藏该部分的页眉和页脚,但没有找到一种方法。 Any help will be appreciated.
任何帮助将不胜感激。
If you're using default section header/footer string settings, you could set them to "" but I believe this will still leave a subtle space where the label/string would usually go. 如果您使用的是默认节的页眉/页脚字符串设置,则可以将它们设置为“”,但我相信这仍会留出通常在标签/字符串处留出的细微空间。
Your other (probably safer) option may be to create a custom Header/Footer class and sizing it accordingly using the frame properties (width/height = 1px). 您的另一个(可能更安全)选项可能是创建自定义Header / Footer类,并使用框架属性(宽度/高度= 1px)相应地调整其大小。 I have not tested this myself, but I used custom classes to render logos next to labels and size everything to my desired width/height.
我自己尚未对此进行测试,但是我使用自定义类在标签旁边呈现徽标,并将所有内容调整为所需的宽度/高度。
Hope this helps. 希望这可以帮助。
Option 1: 选项1:
+++ Section(header: "", footer: "") {_ in
}
Update for Swift 4 and Eureka 4.0.1: Swift 4和Eureka 4.0.1的更新:
Option 2: 选项2:
+++ Section(){ (section) in
section.header = HeaderFooterView<NoHeader>(HeaderFooterProvider.class)
}
class NoHeader: UIView {
override init(frame: CGRect) {
super.init(frame: CGRect(x: 0, y: -1, width: 1, height: 1))
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
Swift 3: 斯威夫特3:
Option 2: 选项2:
+++ Section(header: "", footer: "") {
$0.header = HeaderFooterView<NoHeader>(HeaderFooterProvider.Class)
}
class NoHeader: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
self.frame = CGRect(x: 1, y: -3, width: 1, height: 1)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}
You can use this code, if your ViewController extend from FormViewController. 如果您的ViewController是从FormViewController扩展的,则可以使用此代码。
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
return nil
}
override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return 0
}
You can also just add this to your FormViewController: 您也可以将其添加到FormViewController中:
self.tableView.sectionFooterHeight = 0
self.tableView.sectionHeaderHeight = 0
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.