I solved this by resizing the UITabBarController
just enough to get the tab bar out of the screen:
- (void)setTabBarHidden:(BOOL)hidden
{
CGRect frame = self.originalViewFrame;
if (hidden)
{
frame.size.height += self.tabBar.size.height;
}
self.view.frame = frame;
}
Then you can add KVO your scroll view:
[scrollView addObserver:self
forKeyPath:@"contentOffset"
options:NSKeyValueObservingOptionOld
context:nil];
And hide/show the tab bar on scroll:
- (void)observeValueForKeyPath:(NSString *)keyPath
ofObject:(id)object
change:(NSDictionary *)change
context:(void *)context
{
CGPoint oldOffset = [(NSValue *)change[NSKeyValueChangeOldKey] CGPointValue];
if (!_hidesBarsOnScroll || _scrollView.contentOffset.y == oldOffset.y)
return;
// Show on scroll up
if (_barsHidden &&
scrollView.contentOffset.y < oldOffset.y &&
scrollView.contentOffset.y + scrollView.bounds.size.height < scrollView.contentSize.height) // Skip on bottom
{
[self.navigationController setNavigationBarHidden:NO
animated:YES]; // Also navigation bar!
[self.tabBarController setTabBarHidden:NO
animated:YES];
_barsHidden = NO;
}
// Hide on scroll down
if (!_barsHidden &&
scrollView.contentOffset.y > 0 && // Skip on top
scrollView.contentOffset.y > oldOffset.y)
{
[self.navigationController setNavigationBarHidden:YES
animated:YES];
[self.tabBarController setTabBarHidden:YES
animated:YES];
_barsHidden = YES;
}
}
You can take a look to this implementation here.