Tableview Sticky Header
Let’s talk about some arts about iOS development. I’m gonna show you how to build sticky header view. Please open the GitHub project here before starting to read. You need some codes to paste into your project. End of the write, it will be like…

1- Creating Sticky Header View
You need to create 2 classes which are StickyHeader and StickyHeaderView. These are base classes which provide us to initialize sticky header component.
2- Add UIScrollView Extension
We need to add an extension function to manage tableview scroll.
The classes are ready to start. The next is calling sticky header and assigning my header view to it.

3- Integrate Sitcky Header with Tableview
Call your view in viewDidLoad and assign to sticky header view.
height: The maximum height.
minimumHeight: The minimum height after scrolling.
4- Dynamic Header
We sometimes want to change header background color dynamically. After adding header view, create navigationView which is an UIView and add to header view. So, I added one more view over MyHeaderView.
NavigationView background color will change by offset. Call scrollViewDidScroll and add this code.
Run
That’s all. Run your project.
Here is the all codes of controller: ViewController
Here is the github project: TableStickyViewExample