https://github.com/Chris-Pan/JPNavigationController
This library provides an fullScreen pop and push gesture for UINavigationController with customize UINavigationBar for each single support.
Features[x] FullScreen pop gesture support
[x] FullScreen push gesture support
[x] Customize UINavigationBar for each single viewController support
[x] Add link view hovering in screen bottom support
[x] Customize pop and push gesture distance on the left side of the screen support
[x] Close pop gesture for single viewController support
[x] Close pop gesture for all viewController support
RequirementsiOS 8.0 or later
Xcode 8.0 or later
Getting StartedRead the UINavigationController全屏pop之为每个控制器自定义UINavigationBar
Read the UINavigationController全屏pop之为每个控制器添加底部联动视图
Read the UINavigationController全屏pop之为控制器添加左滑push
Try the example by downloading the project from Github
CommunicationIf you found a bug, open an issue.
If you have a feature request, open an issue.
If you want to contribute, submit a pull request.
InstallationHow To UseInitializeObjective-C: #import <JPNavigationControllerKit.h> JPNavigationController *nav = [[JPNavigationController alloc]initWithRootViewController:YourVc];PushViewControllerObjective-C: [self.navigationController pushViewController:YourVc animated:YES];PopToViewControllerObjective-C: [self.navigationController popViewControllerAnimated:YES]; [self.navigationController popToRootViewControllerAnimated:YES]; // Pop to a given view controller. // Plan A: find the target view controller by youself, then pop it. JPSecondVC *second = nil; NSArray *viewControllers = self.navigationController.jp_rootNavigationController.jp_viewControllers; for (UIViewController *c in viewControllers) { if ([c isKindOfClass:[JPSecondVC class]]) { second = (JPSecondVC *)c; } } if (second) { [self.navigationController popToViewController:second animated:YES]; } // Plan B: use jp_popToViewControllerClassIs: animated:. [self.navigationController jp_popToViewControllerClassIs:[JPSecondVC class] animated:YES];Customize UINavigationBarObjective-C: // Hide navigation bar. self.navigationController.navigationBarHidden = YES; // Customize UINavigationBar color [self.navigationController.navigationBar setBackgroundImage:aImage forBarMetrics:UIBarMetricsDefault]; Add push gesture connect viewControllerObjective-C: // Become the delegate of JPNavigationControllerDelegate protocol and, implemented protocol method, then you own left-slip to push function. self.navigationController.jp_delegate = self; // Implementation protocol method -(void)jp_navigationControllerDidPushLeft{ [self.navigationController pushViewController:YourVc animated:YES]; }Add link view hovering in screen bottomObjective-C: // You must set jp_linkViewHeight in last viewController. // You must call pushViewController:animated: first before set jp_linkViewHeight. [self.navigationController pushViewController:YourVc animated:YES]; YourVc.navigationController.jp_linkViewHeight = 44.0f; // Return the link view in the be pushed viewController. -(void)viewDidLoad{ [super viewDidLoad]; self.navigationController.jp_linkView = YourLinkView; }Customize pop gesture distanceObjective-C: self.navigationController.jp_interactivePopMaxAllowedInitialDistanceToLeftEdge = aValue;Close pop gesture for single viewControllerObjective-C: self.navigationController.jp_closePopForAllViewController = YES;Close pop gesture for all viewControllerObjective-C: self.navigationController.jp_closePopForAllViewController = YES;InstallationThere are two ways to use JPNavigationController in your project:
using CocoaPods
by cloning the project into your repository
Installation with CocoaPodsCocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the section for more details.
Podfileplatform :ios, '8.0' target “YourProjectName” do pod 'JPNavigationController', '~> 1.1.0' endLicensesAll source code is licensed under the MIT License.
如果你在天朝框架支持为 UINavigationController 提供全屏 pop 和 push 手势支持, 并且你可以为每个控制器自定义 UINavigationBar, 注意, 每个控制器的 UINavigationBar 是互不干扰的. 实现基于AOP思想, 不会侵入你的项目.
特性[x] 全屏pop手势支持
[x] 全屏push到绑定的控制器支持
[x] 为每个控制器定制 UINavigationBar 支持(包括设置颜色和透明度)
[x] 为每个控制器添加底部联动视图支持
[x] 自定义pop手势范围支持(从屏幕最左侧开始计算宽度)
[x] 为单个控制器关闭pop手势支持
[x] 为所有控制器关闭pop手势支持
组件要求iOS 8.0 or later
Xcode 8.0 or later
了解实现思路和源码解析阅读我的简书文章 UINavigationController全屏pop之为每个控制器自定义UINavigationBar
阅读我的简书文章 UINavigationController全屏pop之为每个控制器添加底部联动视图
阅读我的简书文章 UINavigationController全屏pop之为控制器添加左滑push
下载我Github上的demo
联系如果你发现了bug, 请帮我提交issue
如果你有好的建议, 请帮我提交issue
#p#分页标题#e#
如果你想贡献代码, 请提交请求
安装具体使用初始化Objective-C: #import <JPNavigationControllerKit.h> JPNavigationController *nav = [[JPNavigationController alloc]initWithRootViewController:YourVc];PushViewControllerObjective-C: [self.navigationController pushViewController:YourVc animated:YES];PopToViewControllerObjective-C: [self.navigationController popViewControllerAnimated:YES]; [self.navigationController popToRootViewControllerAnimated:YES]; // 弹出到指定的控制器 // 方案A: 找到目标控制器, pop JPSecondVC *second = nil; NSArray *viewControllers = self.navigationController.jp_rootNavigationController.jp_viewControllers; for (UIViewController *c in viewControllers) { if ([c isKindOfClass:[JPSecondVC class]]) { second = (JPSecondVC *)c; } } if (second) { [self.navigationController popToViewController:second animated:YES]; } // 方案B: 使用 jp_popToViewControllerClassIs: animated:. [self.navigationController jp_popToViewControllerClassIs:[JPSecondVC class] animated:YES];自定义 UINavigationBarObjective-C: // 隐藏导航条. self.navigationController.navigationBarHidden = YES; // 自定义 UINavigationBar 颜色 [self.navigationController.navigationBar setBackgroundImage:aImage forBarMetrics:UIBarMetricsDefault]; 添加push手势绑定控制器Objective-C: // 成为JPNavigationControllerDelegate协议的代理, 实现协议方法即可拥有左滑push功能. self.navigationController.jp_delegate = self; // 实现协议方法 -(void)jp_navigationControllerDidPushLeft{ [self.navigationController pushViewController:YourVc animated:YES]; }添加底部联动视图支持Objective-C: // 你需要在push之前就把 jp_linkViewHeight 的值传给框架. // 注意: 这两行代码有逻辑关系,必须先push过去,开题报告,navigationController才会alloc,开题报告,分配内存地址,才有值. [self.navigationController pushViewController:YourVc animated:YES]; YourVc.navigationController.jp_linkViewHeight = 44.0f; // 你只需要在 viewDidLoad: 方法里把你的联动视图传给框架, 框架会制动帮你显示. -(void)viewDidLoad{ [super viewDidLoad]; self.navigationController.jp_linkView = YourLinkView; }自定义 pop 手势响应范围Objective-C: self.navigationController.jp_interactivePopMaxAllowedInitialDistanceToLeftEdge = aValue;禁用单个控制器 pop 手势Objective-C: self.navigationController.jp_closePopForAllViewController = YES;禁用所有控制器 pop 手势Objective-C: self.navigationController.jp_closePopForAllViewController = YES;集成到你的项目两种选择把框架集成到你的项目:
使用 CocoaPods
下载我的demo, 把'JPNavigationController'文件夹拽到你的项目中
使用 CocoaPods 安装CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the section for more details.
Podfileplatform :ios, '8.0' target “YourProjectName” do pod 'JPNavigationController', '~> 1.1.0' end证书All source code is licensed under the MIT License.
如果喜欢我的文章,请帮忙点个