Have you ever received what you were looking for? I have this in some code some time ago that does what you ask for. Shows the search bar in the header when removing 40px. Hides under the navigation bar when the table scrolls 40 pixels.
search is the iVar flag that I set when the search bar is active.
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
CGFloat amountOfDrag = scrollView.contentOffset.y;
UIEdgeInsets edgeAtEntry = self.tableView.contentInset;
UIEdgeInsets edgeSetNew;
CGFloat underlay = self.topLayoutGuide.length;
CGFloat searchBarViewHeight = 44.0f;
BOOL needsReset = NO;
if (amountOfDrag <= -40 && edgeAtEntry.top == underlay - searchBarViewHeight) {
needsReset = YES;
edgeSetNew = UIEdgeInsetsMake(0.0f + underlay, 0.0f, self.bottomLayoutGuide.length, 0.0f);
} else if (amountOfDrag >= 40 && edgeAtEntry.top != underlay - searchBarViewHeight) {
needsReset = YES;
edgeSetNew = UIEdgeInsetsMake(-searchBarViewHeight + underlay, 0.0f, self.bottomLayoutGuide.length, 0.0f);
}
if (needsReset && !searching) {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.2];
scrollView.contentInset = edgeSetNew;
[UIView commitAnimations];
}
}