Handling the height of a UITableView header is very similar to handling the height for a cell. When you want to make it dynamic, you need to call layoutIfNeeded
for the header in the tableView:heightForHeaderInSection:
method and return the resulting frame's height.
An excellent, in depth, description of this can be in this StackOverflow questionStackOverflow question.