The UITable​View​Header​Footer​View class implements a reusable view that can be placed at the top or bottom of a table section. You use headers and footers to display additional information for that section.


You can use this class as-is without subclassing in most cases. If you have custom content to display, create the subviews for your content and add them to the view in the content​View property. You can also assign an optional background view to the background​View property. If you do not want to add custom subviews, you can use the text​Label property to display some descriptive text in the view. You can also implement table​View(_:​title​For​Header​In​Section:​): (or table​View(_:​title​For​Footer​In​Section:​)) to display a custom section title without needing to use custom subviews. Tables in grouped style additionally support the detail​Text​Label property.

To make the table view aware of your header or footer view, you need to register it. You do this using the register(_:​for​Header​Footer​View​Reuse​Identifier:​) or register(_:​for​Header​Footer​View​Reuse​Identifier:​) method of UITable​View.


Initializing the View

init(reuse​Identifier:​ String?)

Initializes a header/footer view with the specified reuse identifier.

Accessing the Content Views

var content​View:​ UIView

The content view of the header or footer.

var background​View:​ UIView?

The background view of the header or footer.

Managing View Reuse

var reuse​Identifier:​ String?

A string used to identify a reusable header or footer.

func prepare​For​Reuse()

Prepares a reusable header or footer view for reuse by the table.

Accessing the Default View Content

var text​Label:​ UILabel?

A primary text label for the view.

var detail​Text​Label:​ UILabel?

A detail text label for the view.

var tint​Color:​ UIColor!

The tint color of the view.