IOS

【功能实现】侧滑返回实现

2017-02-07  本文已影响447人  小子爱搞事

[iOS]UINavigationController全屏pop之为每个控制器添加底部联动视图
http://www.jianshu.com/p/3ed21414551a


侧滑返回问题


一个好用的第三方

一个丝滑的全屏滑动返回手势 [http:\\blog.sunnyxx.com\2015\06\07\fullscreen-pop-gesture](http://blog.sunnyxx.com/2015/06/07/fullscreen-pop-gesture/)

github地址:https:\\github.com\forkingdog\FDFullscreenPopGesture

禁止导航栏侧滑返回

navigationController.fd_fullscreenPopGestureRecognizer.enabled = NO;

禁止控制器侧滑返回

viewController.fd_interactivePopDisabled = YES;

隐藏导航栏

// 注意:在viewWillAppear方法中使用无效
- (void)viewDidLoad {
    [super viewDidLoad];
    self.fd_prefersNavigationBarHidden = YES;
}

如果想要scrollView(或之类)支持全屏策侧滑返回(scrollView滚动到最左的时候),自定义的scrollView,实现此方法

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    if (self.contentOffset.x <= 0) {
      if ([otherGestureRecognizer.delegate isKindOfClass:NSClassFromString(@"_FDFullscreenPopGestureRecognizerDelegate")]) {
          return YES;
      }
    }
    return NO;
}

设置侧滑范围:

默认情况下是全屏侧滑

[self setFd_interactivePopMaxllowedInitialistanceToLeftEdge:20];

上一篇下一篇

猜你喜欢

热点阅读