A growing title in a UITableView as the user draws

I am trying to add a UIView over a UITableView. The goal is that as the user pulls the content down (as usual for dragging and dropping), instead of the UITableView background being displayed, the UIView above the table should grow to stay on top of the UITableViewCell that slides down when the user scrolls another path (content increases), the UIView will disappear, as if it were just the top UITableViewCell.

You can see this implementation on the Way (expand the timeline and the top profile image, example at 0:15 ) and the new Facebook app checkin (with a map growing above the list of neighboring places).

Not sure if this is the best way. I think in order to achieve a similar effect you will have to have a UIView as the first cell. But this question worries me a bit, trying to resize the cell height when scrolling. Theoretically, resizing should only happen as they are pulled down, and not squeezed if it is only the top UITableViewCell.

Edit: Current code is using the offer from rummad. I add a keypath observer to the tableview for contentOffset and resizing the cell based on this, but it jumps everywhere.

-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context{
    if (self.tableView == (UITableView*)object) {
        if ([keyPath isEqualToString:@"contentOffset"]) {
            CGPoint scrollLoc = self.tableView.contentOffset;
            if (scrollLoc.y < 0) {
                NSLog(@"offset:%@", NSStringFromCGPoint(scrollLoc));
                headerSize = 100 - scrollLoc.y;
                [self.tableView beginUpdates];
                [self.tableView endUpdates];
            }
        }
    }
}
+5
source share
2 answers

viewDidScroll: contentOffset UITableView. UIView.

+4

All Articles