• Stars
    star
    942
  • Rank 48,525 (Top 1.0 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 11 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Scroll to full screen like Facebook app

NJKScrollFullSrceen

NJKScrollFullSrceen is Facebook App like scroll to full screen library.

This repository consists of full screen delegate and full screen UI behaivior module.

  • NJKScrollFullScreen
  • Simple UIScrollViewDelegate wrapper. It called delegate methods when full screen wanted.
  • UIViewController+NJKFullScreenSupport
  • Add full screen behaivior to UIViewController.

These modules are individual. You can implement your own customized full screen behavior without UIViewController+NJKFullScreenSupport. NJKScrollFullSrceen can apply not only UIScrollView but also UIWebView and UITableView.

Requirements

  • iOS 5.0 or later
  • ARC

Install

CocoaPods

pod 'NJKScrollFullScreen'

Usage

1. Instance NJKScrollFullScreen

Instance and set UIScrollViewDelegate on your view controller. If you set scrollViewDelegate, NJKScrollFullScreen suould perform as a proxy object.

- (void)viewDidLoad
{
    [super viewDidLoad];

    _scrollProxy = [[NJKScrollFullScreen alloc] initWithForwardTarget:self]; // UIScrollViewDelegate and UITableViewDelegate methods proxy to ViewController
    self.tableView.delegate = (id)_scrollProxy; // cast for surpress incompatible warnings
    _scrollProxy.delegate = self;
}

2. Implement delegate methods

- (void)scrollFullScreen:(NJKScrollFullScreen *)proxy scrollViewDidScrollUp:(CGFloat)deltaY
{
    [self moveNavigationBar:deltaY animated:YES];
}

- (void)scrollFullScreen:(NJKScrollFullScreen *)proxy scrollViewDidScrollDown:(CGFloat)deltaY
{
    [self moveNavigationBar:deltaY animated:YES];
}

- (void)scrollFullScreenScrollViewDidEndDraggingScrollUp:(NJKScrollFullScreen *)proxy
{
    [self hideNavigationBar:YES];
}

- (void)scrollFullScreenScrollViewDidEndDraggingScrollDown:(NJKScrollFullScreen *)proxy
{
    [self showNavigationBar:YES];
}

3. Implement full screen behavior

You can choose UIViewController+NJKFullScreenSupport or your own view management code.

Use UIViewController+NJKFullScreenSupport.h.

#import "UIViewController+NJKFullScreenSupport.h"

Or you can implement own full screen behavior like below.

- (void)showNavigationBar:(BOOL)animated
{
    CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
    [self setNavigationBarOriginY:statusBarHeight animated:animated];
}

- (void)hideNavigationBar:(BOOL)animated
{
    [self setNavigationBarOriginY:0 animated:animated];
}

- (void)moveNavigationBar:(CGFloat)deltaY animated:(BOOL)animated
{
    CGRect frame = self.navigationController.navigationBar.frame;
    CGFloat nextY = frame.origin.y + deltaY;
    [self setNavigationBarOriginY:nextY animated:animated];
}

- (void)setNavigationBarOriginY:(CGFloat)y animated:(BOOL)animated
{
    CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
    CGRect frame = self.navigationController.navigationBar.frame;
    CGFloat navigationBarHeight = frame.size.height;

    frame.origin.y = fmin(fmax(y, navigationBarHeight), statusBarHeight); // limit over moving

    [UIView animateWithDuration:animated ? 0.1 : 0 animations:^{
        self.navigationController.navigationBar.frame = frame;
    }];
}

License

MIT license.

More Repositories

1

NJKWebViewProgress

UIWebView progress interface
Objective-C
3,900
star
2

ReSwift-Twitter-Demo

A ReSwift example
Swift
27
star
3

EDAMSync

Test implementation for Evernote Data Access and Management (EDAM)
Objective-C
24
star
4

blog-feedback-app

Visualize your blog's impact
TypeScript
24
star
5

rubymotion-irc

IRC Client with RubyMotion
Ruby
23
star
6

Android-Redux-Twitter-Demo

A Redux example for Android
Java
20
star
7

NSCacheTest

NSCache sample app
Objective-C
11
star
8

ScrollFullScreen

Scroll to full screen for Android
Java
11
star
9

AlertResume

Network error handling sample app
Objective-C
5
star
10

Learning-Programming-Collective-Intelligence

Implement "Programming Collective Intelligence" code with Perl
Perl
3
star
11

ios-programming-the-big-nerd-ranch-guide

Exercises for iOS Programming: The Big Nerd Ranch Guide (2nd Edition)
Objective-C
3
star
12

bon3-ios

bon3 app
Objective-C
2
star
13

vue-slow-performance-sample

Roppongi.vue #4で使うデモアプリ https://scrapbox.io/ninjinkun/Vue%E3%81%AE%E3%83%AA%E3%82%A2%E3%82%AF%E3%83%86%E3%82%A3%E3%83%96%E3%82%B7%E3%82%B9%E3%83%86%E3%83%A0%E3%82%92%E7%90%86%E8%A7%A3%E3%81%97%E3%81%A6%E3%83%91%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%B3%E3%82%B9%E4%BD%8E%E4%B8%8B%E3%82%92%E9%98%B2%E3%81%94%E3%81%86_(Roppongi.vue_%234_)
Vue
2
star
14

RestoreSample

UIStateRestorationのサンプルコードです
Objective-C
1
star
15

VariableHeightCellDemo

Objective-C
1
star
16

intern2010

2010年のはてなインターン用サンプルプロジェクトです
Perl
1
star
17

firebase-todo-sample

社内Firebase勉強会用のvue製Todoリスト
Vue
1
star
18

TwitterSample

勉強会用のiPhoneアプリTwitterクライアントのサンプルコードです
Objective-C
1
star