Skip to content

dailymotion/ZMScrollableNavigationBar

Repository files navigation

Version License Platform

ZMScrollableNavigationBar

A UINavigationController subclass that allows the UINavigationBar to scroll with the content (iOS 8 only)

Click on the image to see a video preview:

Screenshot

Installation

###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.

Usage

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];

TODO

  • Handle Rotation
  • Show UINavigationBar again when user quickly swipes up

About

A UINavigationController category that allows the UINavigationBar to scroll with the content (iOS 8 only)

Resources

License

Stars

Watchers

Forks

Packages

No packages published