A UINavigationController subclass that allows the UINavigationBar to scroll with the content (iOS 8 only)
Click on the image to see a video preview:
###With CocoaPods
Just add pod 'ZMScrollableNavigationBar', '~> 1.0.1'
to your Podfile and run
$> pod install
###Without CocoaPods
Just drag'n'drop UINavigationController+ZMScrollable.h
and UINavigationController+ZMScrollable.m
into your XCode project.
Using a UIScrollView
in your UIViewController
, you can simply hook up the scroll to the UINavigationBar
animation. Here are the two methods you need to implement:
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
self.navigationController.topOffset = -self.scrollView.contentOffset.y;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
self.navigationController.topOffset = -scrollView.contentOffset.y;
}
ZMScrollableNavigationBar also provides a method to reset the navigation bar's offset (for example when another view is pushed). Just call:
[self.navigationController resetTopOffset];
- Handle Rotation
- Show
UINavigationBar
again when user quickly swipes up