The development of iOS | group to modify the position of tableView head hover

The development of iOS | group to modify the position of tableView head hover
professional Gao Jianli, ask a play Cai Wenji small partner, stable points

Background:

Recently, the company mall APP integral page revision, there is one detail is that tableView is full screen, but up and down, requiring the group head docked under the navigation bar below. The effect is approximately as follows:

The development of iOS | group to modify the position of tableView head hover
display effect.Gif

Did the group head hover effect students should know: if only set the tableView style to UITableViewStylePlain, without any treatment, the group head is hovering position at the top of the tableView, obviously can not meet the demand.

Thinking:

Indirectly modify the tableView’s head hover position by modifying the tableView of the contentInset.

Reference code:

- (void) scrollViewDidScroll: (UIScrollView *) scrollView{CGFloat offsetY = scrollView.contentOffset.y; / / self.naviView.backgroundColor = [[UIColor change the navigation and transparency of greenColor] (colorWithAlphaComponent: (offsetY - 64) / 150]); / / modify group head hanging position (offsetY > if = 200) {self.tableView.contentInset = UIEdgeInsetsMake (64, 0, 0, 0);}else{self.tableView.contentInset = UIEdgeInsetsMake (0, 0, 0, 0);}}

Demo:

GitHub demo