CocoaPods trunk is moving to be read-only. Read more on the blog, there are 19 months to go.
TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Nov 2017 |
Maintained by NewPan.
This library provides an fullScreen pop and push gesture for UINavigationController with customize UINavigationBar for each single support and, smooth playing video use AVPlayer
when perform pop gesture support.
AVPlayer
when perform pop gesture supportObjective-C:
#import <JPNavigationControllerKit.h>
JPNavigationController *nav = [[JPNavigationController alloc]initWithRootViewController:YourVc];
Objective-C:
[self.navigationController pushViewController:YourVc animated:YES];
Objective-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.
JPNavigationControllerDemo_linkBar *vc = nil;
NSArray *viewControllers = self.navigationController.jp_rootNavigationController.jp_viewControllers;
for (UIViewController *c in viewControllers) {
if ([c isKindOfClass:[JPNavigationControllerDemo_linkBar class]]) {
vc = (JPNavigationControllerDemo_linkBar *)c;
break;
}
}
if (vc) {
[self.navigationController popToViewController:vc animated:YES];
}
// Plan B: use jp_popToViewControllerClassString:handle:animated:.
[self.navigationController jp_popToViewControllerClassString:@"JPNavigationControllerDemo_linkBar" handle:^UIViewController * _Nullable(NSArray<UIViewController *> * _Nullable viewControllers, NSError * _Nullable error) {
if (!error) {
return viewControllers.firstObject;
}
else{
NSLog(@"%@", error);
return nil;
}
} animated:YES];
Objective-C:
// Hide navigation bar.
self.navigationController.navigationBarHidden = YES;
// Customize UINavigationBar color
[self.navigationController.navigationBar setBackgroundImage:aImage forBarMetrics:UIBarMetricsDefault];
Objective-C:
// Become the delegate of JPNavigationControllerDelegate protocol and, implemented protocol method, then you own left-slip to push function.
[self.navigationController jp_registerNavigtionControllerDelegate:self];
// Implementation protocol method
- (void)navigationControllerDidPush:(JPNavigationController *)navigationController{
[self.navigationController pushViewController:YourVc animated:YES];
}
Objective-C:
// Return the link view in the be pushed viewController.
- (void)viewDidLoad{
[super viewDidLoad];
YourVc.navigationController.jp_linkViewHeight = 44.0f;
self.navigationController.jp_linkView = YourLinkView;
}
Objective-C:
self.navigationController.jp_interactivePopMaxAllowedInitialDistanceToLeftEdge = aValue;
Objective-C:
self.navigationController.jp_closePopForAllViewController = YES;
Objective-C:
self.navigationController.jp_closePopForAllViewController = YES;
Objective-C:
self.navigationController.jp_useCustomPopAnimationForCurrentViewController = YES;
There are two ways to use JPNavigationController in your project:
CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the Get Started section for more details.
platform :ios, '8.0'
target "YourProjectName" do
pod 'JPNavigationController', '~> 2.1.2'
end
All source code is licensed under the MIT License.
框架支持为 UINavigationController 提供全屏 pop 和 push 手势支持, 并且你可以为每个控制器自定义 UINavigationBar, 注意, 每个控制器的 UINavigationBar 是互不干扰的. 实现基于AOP思想, 不会侵入你的项目.
AVPlayer
播放视频的时候, 使用自定义的 pop 动画以保证 AVPlayer
流畅播放.阅读我的简书文章 [iOS]UINavigationController全屏 pop 之为每个控制器自定义UINavigationBar
阅读我的简书文章 [iOS]调和 pop 手势导致 AVPlayer 播放卡顿
下载我Github上的demo
Objective-C:
#import <JPNavigationControllerKit.h>
JPNavigationController *nav = [[JPNavigationController alloc]initWithRootViewController:YourVc];
Objective-C:
[self.navigationController pushViewController:YourVc animated:YES];
Objective-C:
[self.navigationController popViewControllerAnimated:YES];
[self.navigationController popToRootViewControllerAnimated:YES];
// 弹出到指定的控制器
// 方案A: 找到目标控制器, pop
JPNavigationControllerDemo_linkBar *vc = nil;
NSArray *viewControllers = self.navigationController.jp_rootNavigationController.jp_viewControllers;
for (UIViewController *c in viewControllers) {
if ([c isKindOfClass:[JPNavigationControllerDemo_linkBar class]]) {
vc = (JPNavigationControllerDemo_linkBar *)c;
break;
}
}
if (vc) {
[self.navigationController popToViewController:vc animated:YES];
}
// 方案 B: jp_popToViewControllerClassString:handle:animated:.
[self.navigationController jp_popToViewControllerClassString:@"JPNavigationControllerDemo_linkBar" handle:^UIViewController * _Nullable(NSArray<UIViewController *> * _Nullable viewControllers, NSError * _Nullable error) {
if (!error) {
return viewControllers.firstObject;
}
else{
NSLog(@"%@", error);
return nil;
}
} animated:YES];
Objective-C:
// 隐藏导航条.
self.navigationController.navigationBarHidden = YES;
// 自定义 UINavigationBar 颜色
[self.navigationController.navigationBar setBackgroundImage:aImage forBarMetrics:UIBarMetricsDefault];
Objective-C:
// 成为JPNavigationControllerDelegate协议的代理, 实现协议方法即可拥有左滑push功能.
[self.navigationController jp_registerNavigtionControllerDelegate:self];
// 实现协议方法
- (void)jp_navigationControllerDidPushLeft{
[self.navigationController pushViewController:YourVc animated:YES];
}
Objective-C:
// 你只需要在 viewDidLoad: 方法里把你的联动视图传给框架, 框架会制动帮你显示.
-(void)viewDidLoad{
[super viewDidLoad];
YourVc.navigationController.jp_linkViewHeight = 44.0f;
self.navigationController.jp_linkView = YourLinkView;
}
Objective-C:
self.navigationController.jp_interactivePopMaxAllowedInitialDistanceToLeftEdge = aValue;
Objective-C:
self.navigationController.jp_closePopForAllViewController = YES;
Objective-C:
self.navigationController.jp_closePopForAllViewController = YES;
Objective-C:
self.navigationController.jp_useCustomPopAnimationForCurrentViewController = YES;
两种选择把框架集成到你的项目:
CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. See the Get Started section for more details.
platform :ios, '8.0'
target "YourProjectName" do
pod 'JPNavigationController', '~> 2.1.2'
end
All source code is licensed under the MIT License.