diff --git a/GKNavigationBar.podspec b/GKNavigationBar.podspec index 3942d2c..8c48f16 100644 --- a/GKNavigationBar.podspec +++ b/GKNavigationBar.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'GKNavigationBar' - s.version = '1.6.0' + s.version = '1.6.1' s.license = 'MIT' s.summary = '自定义导航栏--导航栏联动' s.homepage = 'https://github.com/QuintGao/GKNavigationBar' diff --git a/GKNavigationBar/GestureHandle/GKBaseAnimatedTransition.h b/GKNavigationBar/GestureHandle/GKBaseAnimatedTransition.h index ee3556f..9979410 100644 --- a/GKNavigationBar/GestureHandle/GKBaseAnimatedTransition.h +++ b/GKNavigationBar/GestureHandle/GKBaseAnimatedTransition.h @@ -41,11 +41,6 @@ NS_ASSUME_NONNULL_BEGIN /// 动画完成 - (void)completeTransition; - -/// 获取某个view的截图 -/// @param view 截图 -- (UIImage *)getCaptureWithView:(UIView *)view; - @end @interface UIViewController (GKCapture) diff --git a/GKNavigationBar/GestureHandle/GKBaseAnimatedTransition.m b/GKNavigationBar/GestureHandle/GKBaseAnimatedTransition.m index 546a582..d83ad57 100644 --- a/GKNavigationBar/GestureHandle/GKBaseAnimatedTransition.m +++ b/GKNavigationBar/GestureHandle/GKBaseAnimatedTransition.m @@ -53,14 +53,6 @@ - (void)completeTransition { [self.transitionContext completeTransition:!self.transitionContext.transitionWasCancelled]; } -- (UIImage *)getCaptureWithView:(UIView *)view { - UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0); - [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO]; - UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - return image; -} - @end @implementation UIViewController (GKCapture) diff --git a/GKNavigationBar/GestureHandle/GKGestureHandleConfigure.h b/GKNavigationBar/GestureHandle/GKGestureHandleConfigure.h index 4de915d..a4d5198 100644 --- a/GKNavigationBar/GestureHandle/GKGestureHandleConfigure.h +++ b/GKNavigationBar/GestureHandle/GKGestureHandleConfigure.h @@ -42,6 +42,9 @@ NS_ASSUME_NONNULL_BEGIN // 如果设置为YES,可在单个UIScrollView中通过设置gk_openGestureHandle关闭 @property (nonatomic, assign) BOOL gk_openScrollViewGestureHandle; +// 设置push时是否隐藏tabbar,默认NO +@property (nonatomic, assign) BOOL gk_hidesBottomBarWhenPushed; + /// 设置默认配置 - (void)setupDefaultConfigure; @@ -56,6 +59,10 @@ NS_ASSUME_NONNULL_BEGIN // 内部方法 - (BOOL)isVelocityInSensitivity:(CGFloat)velocity; +/// 获取某个view的截图 +/// @param view view +- (UIImage *)getCaptureWithView:(UIView *)view; + @end NS_ASSUME_NONNULL_END diff --git a/GKNavigationBar/GestureHandle/GKGestureHandleConfigure.m b/GKNavigationBar/GestureHandle/GKGestureHandleConfigure.m index 1b3ac53..c8ca1f8 100644 --- a/GKNavigationBar/GestureHandle/GKGestureHandleConfigure.m +++ b/GKNavigationBar/GestureHandle/GKGestureHandleConfigure.m @@ -56,4 +56,12 @@ - (BOOL)isVelocityInSensitivity:(CGFloat)velocity { return (fabs(velocity) - (1000.0f * (1 - self.gk_snapMovementSensitivity))) > 0; } +- (UIImage *)getCaptureWithView:(UIView *)view { + UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0); + [view drawViewHierarchyInRect:view.bounds afterScreenUpdates:NO]; + UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); + UIGraphicsEndImageContext(); + return image; +} + @end diff --git a/GKNavigationBar/GestureHandle/GKPushAnimatedTransition.m b/GKNavigationBar/GestureHandle/GKPushAnimatedTransition.m index f04061a..b2c3904 100644 --- a/GKNavigationBar/GestureHandle/GKPushAnimatedTransition.m +++ b/GKNavigationBar/GestureHandle/GKPushAnimatedTransition.m @@ -21,7 +21,7 @@ - (void)animateTransition { __block UIView *fromView = nil; if (self.isHideTabBar) { // 获取fromViewController的截图 - UIImage *captureImage = [self getCaptureWithView:self.fromViewController.view.window]; + UIImage *captureImage = [GKGestureConfigure getCaptureWithView:self.fromViewController.view.window]; UIImageView *captureView = [[UIImageView alloc] initWithImage:captureImage]; captureView.frame = CGRectMake(0, 0, screenW, screenH); [self.containerView addSubview:captureView]; diff --git a/GKNavigationBar/GestureHandle/UINavigationController+GKGestureHandle.m b/GKNavigationBar/GestureHandle/UINavigationController+GKGestureHandle.m index 3463e8a..8bcbd07 100644 --- a/GKNavigationBar/GestureHandle/UINavigationController+GKGestureHandle.m +++ b/GKNavigationBar/GestureHandle/UINavigationController+GKGestureHandle.m @@ -64,15 +64,16 @@ + (void)load { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ NSArray *oriSels = @[@"viewDidLoad", + @"pushViewController:animated:", @"navigationBar:shouldPopItem:", @"dealloc"]; [oriSels enumerateObjectsUsingBlock:^(NSString * _Nonnull oriSel, NSUInteger idx, BOOL * _Nonnull stop) { - gk_gestureHandle_swizzled_instanceMethod(@"gkNav", self, oriSel, self); + gk_gestureHandle_swizzled_instanceMethod(@"gkGesture", self, oriSel, self); }]; }); } -- (void)gkNav_viewDidLoad { +- (void)gkGesture_viewDidLoad { if (self.gk_openGestureHandle) { // 处理特殊控制器 if ([self isKindOfClass:[UIImagePickerController class]]) return; @@ -88,11 +89,26 @@ - (void)gkNav_viewDidLoad { // 注册控制器属性改变通知 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(propertyChangeNotification:) name:GKViewControllerPropertyChangedNotification object:nil]; } - [self gkNav_viewDidLoad]; + [self gkGesture_viewDidLoad]; +} + +- (void)gkGesture_pushViewController:(UIViewController *)viewController animated:(BOOL)animated { + if (self.childViewControllers.count > 0) { + UIViewController *rootVC = self.childViewControllers.firstObject; + // 获取tabbar截图 + if (viewController.gk_systemGestureHandleDisabled && !rootVC.gk_captureImage) { + rootVC.gk_captureImage = [GKGestureConfigure getCaptureWithView:rootVC.view.window]; + } + // 设置push时是否隐藏tabbar + if (GKGestureConfigure.gk_hidesBottomBarWhenPushed && rootVC != viewController) { + viewController.hidesBottomBarWhenPushed = YES; + } + } + [self gkGesture_pushViewController:viewController animated:animated]; } // source:https://github.com/onegray/UIViewController-BackButtonHandler -- (BOOL)gkNav_navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item { +- (BOOL)gkGesture_navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item { if ([self.viewControllers count] < [navigationBar.items count]) { return YES; } @@ -119,11 +135,11 @@ - (BOOL)gkNav_navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINa return NO; } -- (void)gkNav_dealloc { +- (void)gkGesture_dealloc { if (self.gk_openGestureHandle) { [[NSNotificationCenter defaultCenter] removeObserver:self name:GKViewControllerPropertyChangedNotification object:nil]; } - [self gkNav_dealloc]; + [self gkGesture_dealloc]; } - (UIViewController *)childViewControllerForStatusBarHidden { diff --git a/GKNavigationBarExample/GKNavigationBarExample.xcodeproj/project.pbxproj b/GKNavigationBarExample/GKNavigationBarExample.xcodeproj/project.pbxproj index c9bb957..f5f026e 100644 --- a/GKNavigationBarExample/GKNavigationBarExample.xcodeproj/project.pbxproj +++ b/GKNavigationBarExample/GKNavigationBarExample.xcodeproj/project.pbxproj @@ -517,7 +517,7 @@ 796CF7E4236D781400983E9B /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1240; + LastUpgradeCheck = 1300; ORGANIZATIONNAME = QuintGao; TargetAttributes = { 79672E92236EC8EB0054300B = { diff --git a/GKNavigationBarExample/GKNavigationBarExample.xcodeproj/xcshareddata/xcschemes/GKNavigationBarFramework.xcscheme b/GKNavigationBarExample/GKNavigationBarExample.xcodeproj/xcshareddata/xcschemes/GKNavigationBarFramework.xcscheme index ba13aca..b831936 100644 --- a/GKNavigationBarExample/GKNavigationBarExample.xcodeproj/xcshareddata/xcschemes/GKNavigationBarFramework.xcscheme +++ b/GKNavigationBarExample/GKNavigationBarExample.xcodeproj/xcshareddata/xcschemes/GKNavigationBarFramework.xcscheme @@ -1,6 +1,6 @@ 最近更新 ``` +1.6.1 - 2021.11.08 1、修复设置gk_systemGestureHandleDisabled后TabBar偏移问题 #90 + 2、新增gk_hidesBottomBarWhenPushed,可全局配置push时是否隐藏TabBar 1.6.0 - 2021.09.09 修复visibleViewController方法返回错误问题 1.5.9 - 2021.06.25 配置类增加backgroundImage,可设置全局导航图片 1.5.8 - 2021.06.09 增加恢复系统导航栏显示的逻辑及方法 #86