Hi everyone,
I am currently learning how to use content configuration (UIListContentConfiguration
, etc., introduced WWDC '20) in UITableView, instead of the now deprecated tools such as cell.textLabel?.text
.
I am trying to implement a section header on an inset grouped table view using the UIListContentConfiguration.groupedHeader()
configuration with a UITableViewHeaderFooterView. However, when I do so, the text is misaligned, several pixels to the left of the cell content's text, aligned with what I assume is text for the grouped table view style rather than the inset grouped table view style.
Here is an ascii art version, as I couldn't figure out how to add images using markdown :)
HELLO <--- Header
____________________
|
| Favorites <--- Table View Cell text
|
The cell is using the UIListContentConfiguration.valueCell()
configuration, in an inset grouped table view. Here is the code for my header:
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerView: UITableViewHeaderFooterView = UITableViewHeaderFooterView()
var content = UIListContentConfiguration.groupedHeader()
content.text = "Hello"
headerView.contentConfiguration = content
return headerView
}
Is there a place to add a layout guide, or constraints I don't know about? Is there another inset grouped style I just don't know about?
Any guidance would be greatly appreciated!
Thank you!
-Thomas