A reusable view that you place at the top or bottom of a table section to display additional information for that section.
SDKs
- iOS 6.0+
- Mac Catalyst 13.0+
- tvOS 9.0+
Framework
- UIKit
Declaration
@interface UITableViewHeaderFooterView : UIView
Overview
Use UITable 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 generate a header or footer with a standard appearance, configure the text property with the text you want to display. (If you configured your table view with the group style, you can also configure the detail property.) To generate a more custom appearance, add subviews to the view in the content property. You can also assign an optional background view to the background property.
To promote the reuse of your header-footer views, register them by calling the register or register method of the table view. In the table or table method of your delegate object, call the table view's dequeue 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 table and table 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.