帮酷LOGO
0 0 评论
  • 显示原文与译文双语对照的内容
文章标签:Facebook  屏幕  滚动  
Scroll to full screen like Facebook app

  • 源代码名称:NJKScrollFullScreen
  • 源代码网址:http://www.github.com/ninjinkun/NJKScrollFullScreen
  • NJKScrollFullScreen源代码文档
  • NJKScrollFullScreen源代码下载
  • Git URL:
    git://www.github.com/ninjinkun/NJKScrollFullScreen.git
  • Git Clone代码到本地:
    git clone http://www.github.com/ninjinkun/NJKScrollFullScreen
  • Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/ninjinkun/NJKScrollFullScreen
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
    
  • NJKScrollFullSrceen

    NJKScrollFullSrceen的Facebook应用就像滚动到全屏库。

    这个库由全屏委托和全屏幕 UI behaivior模块组成。

    • NJKScrollFullScreen
    • 简单的UIScrollViewDelegate包装器。在全屏显示时调用委托方法。
    • UIViewController+NJKFullScreenSupport
    • 向UIViewController添加全屏 behaivior。

    这些模块是独立的。你可以实现自己的自定义全屏行为,而无需 UIViewController+NJKFullScreenSupportNJKScrollFullSrceen 不仅可以应用 UIScrollView,还可以应用UIWebView和 UITableView。

    要求
    • iOS 5.0或者更高版本
    • ARC
    安装

    CocoaPods

    
    pod 'NJKScrollFullScreen'
    
    
    
    
    用法

    1实例 NJKScrollFullScreen

    实例并在视图控制器上设置 UIScrollViewDelegate。 如果设置了 scrollViewDelegateNJKScrollFullScreen suould将作为代理对象执行。

    - (void)viewDidLoad
    {
     [superviewDidLoad];
     _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实现委托方法

    - (void)scrollFullScreen:(NJKScrollFullScreen *)proxy scrollViewDidScrollUp:(CGFloat)deltaY
    {
     [selfmoveNavigationBar:deltaY animated:YES];
    }
    - (void)scrollFullScreen:(NJKScrollFullScreen *)proxy scrollViewDidScrollDown:(CGFloat)deltaY
    {
     [selfmoveNavigationBar:deltaY animated:YES];
    }
    - (void)scrollFullScreenScrollViewDidEndDraggingScrollUp:(NJKScrollFullScreen *)proxy
    {
     [selfhideNavigationBar:YES];
    }
    - (void)scrollFullScreenScrollViewDidEndDraggingScrollDown:(NJKScrollFullScreen *)proxy
    {
     [selfshowNavigationBar:YES];
    }

    3实现全屏幕行为

    在 功能表 中 选择 UIViewController+NJKFullScreenSupport 或者你自己的视图管理代码。

    用户 UIViewController+NJKFullScreenSupport.h

    #import"UIViewController+NJKFullScreenSupport.h"

    或者你可以实现自己的全屏行为,如下所示。

    - (void)showNavigationBar:(BOOL)animated
    {
     CGFloat statusBarHeight = [UIApplication sharedApplication].statusBarFrame.size.height;
     [selfsetNavigationBarOriginY:statusBarHeight animated:animated];
    }
    - (void)hideNavigationBar:(BOOL)animated
    {
     [selfsetNavigationBarOriginY:0animated:animated];
    }
    - (void)moveNavigationBar:(CGFloat)deltaY animated:(BOOL)animated
    {
     CGRect frame = self.navigationController.navigationBar.frame;
     CGFloat nextY = frame.origin.y + deltaY;
     [selfsetNavigationBarOriginY: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 : 0animations:^{
     self.navigationController.navigationBar.frame = frame;
     }];
    }
    许可证

    MIT许可证。



    文章标签:屏幕  滚动  Facebook  

    Copyright © 2011 HelpLib All rights reserved.    知识分享协议 京ICP备05059198号-3  |  如果智培  |  酷兔英语