List with fixed header bounce effect like App Stor

2019-05-31 05:00发布

问题:

I want to make a UITableView with a fixed header, like the App Store, with the bounce effect below the header:

I've tried a UIScrollView with a UITableView with scrollEnabled NO. Didn't work; it didn't make the bounce effect below the header:

My View:

回答1:

I finally found one solution. Basically I created a UITableView and a header, both with clear background color. Then I add a new view (with the same height that the header tableView has), between the controller view and tableView, positioned at the top. This new view is the header. I then use the function scrollViewDidScroll to manage the position of the view that simulates the header. This way I could achieve the bounce in the tableView below the header

I have made an example, you can download it here