Reputation: 499
I want to display some text (I guess in the header section) of a tableview when the user scrolls it. Kind of like pull to refresh, but just a message. Does anyone know the best way to do this? I Just want to show text so I think the UIRefresh control is kind of out. Thanks!
Upvotes: 0
Views: 56
Reputation: 6899
Here is the code to place a message in the tableViewHeader
:
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 20)];
label.text = @"Hello, World!";
label.textColor = [UIColor blackColor];
self.tableView.tableHeaderView = label;
[self.tableView setContentInset:UIEdgeInsetsMake(-label.bounds.size.height, 0.0f, 0.0f, 0.0f)];
}
Upvotes: 1