JDFPeekaboo is a simple class that hides the navigation bar when you scroll down, and shows it again when you scroll back up. It can actually be any UIView that it hides, and it will also hide a view at the bottom of the screen as well, if you like.
Here's a little demo of it in use:
It's very easy to use. Simply add a property for it:
@property (nonatomic, strong) JDFPeekabooCoordinator *scrollCoordinator;
Then, set it up (say, in
self.scrollCoordinator = [[JDFPeekabooCoordinator alloc] init]; self.scrollCoordinator.scrollView = self.scrollView; self.scrollCoordinator.topView = self.navigationController.navigationBar; self.scrollCoordinator.bottomView = self.navigationController.toolbar;
Sometimes, you may want to temporarily disable
JDFPeekaboo, for example when you push another view controller onto your navigation controller. Some convenience methods are provided for disabling
JDFPeekaboo (and re-enabling it). See the documentation for more info.
You can also find a bit more info on my blog post
Q: Why are there black spaces at the top/bottom of the screen, like this:
A: This happens if your table view doesn't extend behind the
tabBar. You can fix this by setting your
UIRectEdgeAll/whatever is appropriate), or by doing the equivalent in interface builder.
To run the example project, clone the repo, and run
pod install from the Example directory first.
JDFPeekaboo is available through CocoaPods. To install it, simply add the following line to your Podfile:
Joe Fryer, email@example.com
Twitter - JoeFryer88
JDFPeekaboo is available under the MIT license. See the LICENSE file for more info.