arooo arooo - 3 months ago 37
Swift Question

Scrolling cells over UITableView with a fixed "Header"

I want the top of my

to be a fixed view that the cells can scroll over like in the gif below. The text will change, and the button should be interactable.

How can I go about this? One idea I had was to add a subview behind the UITableView and offset the contentInset, but that would make the button unusable AFAIK.

Any ideas?

enter image description here


You can try this solution:

add the header view to container view, then add tableview as the header view's subview.

override tableview's method:

  • (BOOL)pointInside:(CGPoint)point withEvent:(nullable UIEvent *)event;

If the header view have visible area(check tableview's contentOffset), and the point is inside the visible area, return false.