IOS uitableview Expandableheader (deformable header)

Source: Internet
Author: User

The most common header is the one in the header that is magnified when the TableView is pulled down .

Recently, I have studied it and realized this kind of header.

1. Set TableView contentinset (reserved for header) and Contentoffset (to show the top of TableView when loading is complete)

0 0 0  0true)

2. Adding a constraint to the header (Snapkit)

var headerheightconstraint:constraint? var headertopconstraint:constraint?

in = M.top.equalto (tableView.snp.top). Offset (-headerheight). Constraint        M.leading.equalto (tableView.snp.leading)    M.width.equalto (screen_width)    = M.height.equalto ( headerheight). Constraint}

3. Monitor the contentoffset of TableView and change the constraints of the header

Let Yoffset =-scrollview.contentoffset.yif yoffset >  headerheight {    Headertopconstraint?. Layoutconstraints.first?. Constant =-yoffset    headerheightconstraint? Layoutconstraints.first?. Constant = Yoffset}

4. Set the Contentmode of the header section (if the mode is not correct, the content will be scaled differently)

// mode Please choose according to the actual situation

Ficow Original, reproduced please specify the source:http://www.cnblogs.com/ficow/p/7301110.html

IOS uitableview Expandableheader (deformable header)

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.