arooo arooo - 1 year ago 114
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

Answer Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download