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)