Example-HeaderScroll
Example-HeaderScroll copied to clipboard
Half image stick on top ?
@NachoMan is it possible stretch half of image and stick on top ?
Sure @atifsaeed14! It's pretty straightforward, but it will require a change to the view hierarchy for how the header is added. The approach I describe here embeds the header view into the table's background. So the header peeks through from where table content doesn't show. So as the table is scrolled, the cells overlap and subsequently overlay the header.
Instead I would suggest adding both the header view and the table view to a common superview (using UIViewController
instead of UITableViewController
), and then ensure the header view is in the front.
In this way you can use the contentInsets
to adjust the starting point of the table content to ensure the header is visible, and you can adjust the height of the header view, but leave its origin at (0,0)
. All that remains is making sure you only adjust the header to some minimum height.