0

The default behavior for UITableView section headers is to stick to the top edge of the table and slightly change background to a thin material.

I need to add a button to the section header, so, as I understand, I need to write my own custom header with the viewForHeaderInSection. How do I replicate the default behavior of changing the background to a thin material? How do I detect that the section header hit the top edge of the table and force to change the view's background?

Alternatively, how can I add a button to the standard header without writing my own?

Grant Oganyan
  • 352
  • 1
  • 11
  • check if this helps you https://stackoverflow.com/questions/41670152/detect-when-uitableview-section-header-snaps-to-the-top-of-the-screen – Void Asif Jul 07 '22 at 05:31
  • 1
    If you subclass UITableViewHeaderFooterView and add your button there, it changes the background to a thin material for you automatically. As far as replicating the behavior maybe you can look at the scrollViewDidScroll delegate method – mrnifnif Jul 07 '22 at 08:03
  • @willThatBeAll UITableViewHeaderFooterView is exactly what I was looking for. Thanks! – Grant Oganyan Jul 07 '22 at 17:08

1 Answers1

0

Creating a simple subclass of UITableViewHeaderFooterView helped. It kept all the standard behavior and visuals, while I just added a button on top.

Grant Oganyan
  • 352
  • 1
  • 11