A clever way to implement the floating tableViewHeader, table border

Source: Internet
Author: User

A clever way to implement the floating tableViewHeader, table border

Previously, we had to implement a similar floating + parallax headerView because of our work. After studying how to do this for a long time, we finally used UICollectionView + CSStickyHeaderFlowLayout(I have to say CSStickyHeaderFlowLayoutIt is really a very powerful library, and the author's understanding of UICollectionView is really profound, it is recommended that you have a look at his source code when you are free ). I used a UICollectionView to implement a UITableView... Later, on gitHub ARSegmentPagerInspired by this, I found another clever way of thinking. It can also achieve this effect better, and it can be achieved with UITableView. The implementation method is also relatively simple, and more extensions can be made, so record it. The core of this idea is to place the custom headerView on the tabView instead of tableView. tableHeaderView (both headerView and tableView are added to the view of viewController), and set the contentInset of tableView as the appropriate value. When the tableView slides, dynamically change the position or size of the view to make the headerView look like a tableView with the floating function. tableHeaderView. I used to think about how to use tableView to implement this function. This method made me jump out of the mindset and put headerView outside, but how can I change it !!! (If you don't say it in advance, you can hardly see that this is not tableHeaderView.) For example: Or: Of course, you can do more cool effects, here are just a few of the simplest and easiest implementations. The specific demo address here: After playing https://github.com/Phelthas/TEST_XMLCommon you may also find the problem, this only when the finger on the tableView to slide, on the headerView will not work ...... This cannot be tolerated. What I think of now is that we can use the hitTest method to pass the gesture through headerView. However, we have no time to try it now. If we are free on weekends, we can try again ~~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.