Contents

UITableViewHeaderFooterView

A reusable view that you place at the top or bottom of a table section to display additional information for that section.

Declaration

@MainActor class UITableViewHeaderFooterView

Mentioned in

Overview

Use UITableViewHeaderFooterView objects to manage the header and footer content of your table’s sections efficiently. A header-footer view is a reusable view that you can subclass or use as is. To configure the content and appearance of a header-footer view, you can set its contentConfiguration and backgroundConfiguration.

To promote the reuse of your header-footer views, register them by calling the register(_:forHeaderFooterViewReuseIdentifier:) or register(_:forHeaderFooterViewReuseIdentifier:) method of the table view. In the tableView(_:viewForHeaderInSection:) or tableView(_:viewForFooterInSection:) method of your delegate object, call the table view’s dequeueReusableHeaderFooterView(withIdentifier:) method to create your view. That method returns a recycled view (if one is available) or creates a new view using the information you registered.

A simple alternative to creating custom header-footer views is to implement the tableView(_:titleForHeaderInSection:) and tableView(_:titleForFooterInSection:) methods of your data source object. When you implement those methods, the table view creates a standard header or footer view and displays the text you supply.

Topics

Creating the view

Managing view reuse

Configuring the background

Managing the content

Managing the state

Deprecated

See Also

Cells, headers, and footers