Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/luugiathuy/GTScrollNavigationBar
A scrollable UINavigationBar that follows a UIScrollView
https://github.com/luugiathuy/GTScrollNavigationBar
ios objective-c uinavigationbar uiscrollview
Last synced: 3 months ago
JSON representation
A scrollable UINavigationBar that follows a UIScrollView
- Host: GitHub
- URL: https://github.com/luugiathuy/GTScrollNavigationBar
- Owner: luugiathuy
- License: bsd-3-clause
- Created: 2013-12-21T08:56:12.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2017-04-26T10:46:03.000Z (over 7 years ago)
- Last Synced: 2024-07-18T15:33:19.388Z (4 months ago)
- Topics: ios, objective-c, uinavigationbar, uiscrollview
- Language: Objective-C
- Homepage:
- Size: 319 KB
- Stars: 552
- Watchers: 26
- Forks: 85
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GTScrollNavigationBar
[![CocoaPods Version](https://img.shields.io/cocoapods/v/GTScrollNavigationBar.svg)](http://cocoadocs.org/docsets/GTScrollNavigationBar) [![Build Status](https://travis-ci.org/luugiathuy/GTScrollNavigationBar.svg?branch=master)](https://travis-ci.org/luugiathuy/GTScrollNavigationBar) [![Coverage Status](https://coveralls.io/repos/luugiathuy/GTScrollNavigationBar/badge.svg?branch=master&service=github)](https://coveralls.io/github/luugiathuy/GTScrollNavigationBar?branch=master)
A lightweight scrollable UINavigationBar that follows a UIScrollView. This project was inspired by the navigation bar functionality seen in the Chrome, Facebook and Instagram iOS apps.
![GTScrollNavigationBar Screenshot 1](http://luugiathuy.com/images/GTScrollNavigationBar1.png) ![GTScrollNavigationBar Screenshot 2](http://luugiathuy.com/images/GTScrollNavigationBar2.png)
## Installation
### CocoaPods
Add pod `GTScrollNavigationBar` to your Podfile.
### Manually
Add the `GTScrollNavigationBar` folder to your project. `GTScrollNavigationBar` uses ARC, so if you have a project that doesn't use ARC, add the `-fobjc-arc` compiler flag to the `GTScrollNavigationBar` files.
## Usage
Set up the navigation controller to use `GTScrollNavigationBar`:
```objective-c
#import "GTScrollNavigationBar.h"self.navController = [[UINavigationController alloc] initWithNavigationBarClass:[GTScrollNavigationBar class]
toolbarClass:nil];
[self.navController setViewControllers:@[self.mainViewController] animated:NO];
```In your view controller which has a `UIScrollView`, e.g. `UITableViewController`, set the UIScrollView object to the `GTScrollNavigationBar` in `viewWillAppear:` or `viewDidAppear:` by:
```objective-c
self.navigationController.scrollNavigationBar.scrollView = self.tableView;
```To unfollow the scrollView, simply set `scrollView` property to `nil`
```objective-c
self.navigationController.scrollNavigationBar.scrollView = nil;
```Implement `scrollViewDidScrollToTop:` in the view controller to reset the navigation bar's position
```objective-c
- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView
{
[self.navigationController.scrollNavigationBar resetToDefaultPositionWithAnimation:NO];
}
```## Contact
[@luugiathuy](http://twitter.com/luugiathuy)