美文网首页
ios导航栏-侧滑

ios导航栏-侧滑

作者: money_ac9e | 来源:发表于2018-07-30 09:25 被阅读0次

参考:iOS导航栏使用总结

一、实现侧滑

直接上代码即可

@interface BaseViewController ()<UIGestureRecognizerDelegate>

@end

@implementationBaseViewController

- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view.

    self.navigationController.interactivePopGestureRecognizer.delegate = self;

}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer*)gestureRecognizer

{

    if (self.navigationController.childViewControllers.count == 1) {

        returnNO;

    }

    return YES;

}

二、隐藏导航栏底部的分割线

```

- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view.    

    UIImageView *navBarBottomImageView = [self findNavBarBottomImage:self.navigationController.navigationBar];

    navBarBottomImageView.hidden=YES;

}

- (UIImageView*)findNavBarBottomImage:(UIView*)view

{

    if ([[view class] isSubclassOfClass:[UIImageView class]]) {

        return(UIImageView*)view;

    }

    for(UIView*subViewinview.subviews) {

        //这里使用递归 很巧妙

        UIImageView*navBarBottomImageView = [selffindNavBarBottomImage:subView];

        if(navBarBottomImageView) {

            returnnavBarBottomImageView;

        }

    }

    return nil;

}

```

附:这个查找的方法使用递归查找很精妙

相关文章

网友评论

      本文标题:ios导航栏-侧滑

      本文链接:https://www.haomeiwen.com/subject/akyxvftx.html