参考: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;
}
```
附:这个查找的方法使用递归查找很精妙
网友评论