ImmutableHeaderFooterProvider
public class ImmutableHeaderFooterProvider<View>: HeaderFooterProvider<View>
where View: Configurable & ReusableView
Default class that is responsible to dequeue a reusable view and configure it
Note
if the height is nil then you should make UIView as a self-sized viewUsage Example
- Create a ReusableView
final class TestReusableView: ReusableView, Configurable {
let label: UILabel
override init(reuseIdentifier: String?) {
// Init and Configure UILabel
super.init(reuseIdentifier: reuseIdentifier)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
func configure(with txt: String) {
label.text = txt
}
}
- Create a header
let text = "My custom section"
let header = ImmutableHeaderFooterProvider<TestReusableView>(model: text)
- Attach the header to a
TableViewDiffableSection
let updates = TableViewDiffableSection(id: "SectionID here")
updates.addHeader(header)
-
Returns configured view
Declaration
Swift
public override func headerView(forTableView tableView: UITableView) -> UIView?
Parameters
tableView
UITableView
used to dequeue the viewReturn Value
UIView?